Python embeding question

This thread is not related to blender. How can I embed and use python in order to modify the values of variables which belong to a c++ appliation ?

Very painfully…

This page covers the basic idea very well. http://docs.python.org/ext/embedding.html

The problem I’ve found with doing development like this is the compiler. Python for windows is built using VC2003 and unless you have it its going to be very painful to create modules, which you need for python to access your C++ code. The thing I got stuck on was disutils is written only for VC2003. If Disutils worked with 2005 then it would be alright…

Added:
After reviewing that page it looks like you might not need to construct a package to use it - in wich case I could use VC2005 - So thats pretty cool.

I think I’ve seen some woodoo howtos on how to compile modules with mingw for windows. Anyhow, it was very voodoo …

Yeah a lot of people say that.

This might be worth looking into.
http://www.cython.org/

I’m going to try writing something in cython then embed it into a C++ app to see if I can get python to access parts of my C++ app. If that works then cool and I’ll post an example.

Why should I use external tools ?

I thought I could use something like that :

#include <Python.h>

int
main(int argc, char *argv[])
{
  Py_Initialize();
  PyRun_SimpleString("from time import time,ctime
"
                     "print 'Today is',ctime(time())
");
  Py_Finalize();
  return 0;
}

What I want is to create python plug-ins for my c++ application.
Something like the blender python editor …
Any ideas ?

http://www.python.org/doc/ext/embedding.html

I have read the pytho documention but what I want is a very simple example at which the values of a c++ app are modified by values generated from a python script (and the opposite)

http://www.python.org/doc/ext/extending-with-embedding.html
You are not going to get a simpler example than provided here. Sorry.

[edit] Sorry, to be less terse: you’ll need to create some routines that pass values to/from the interpreter. For example, in the Blender API, there are a ton of GetThis() and SetThat() routines, which do exactly [ed]the kind of thing[/ed] you want. [ed]For example: Blender.Get(‘curframe’) gets the blender internal variable for the current frame and returns it to the script.[/ed]

Hope this helps.[/edit]

Exactly that is covered in the documentation behind that link.

I was going to post this earlier and I guess by now you probably don’t need it but section 5.3 of the document did have an example that did what you wanted.

http://www.python.org/doc/ext/pure-embedding.html

Added:
Woops… 5.4 is what you were trying to do and someone already posted that.