Embedding/Extending Python in C++

Kirby

Lifer
Apr 10, 2006
12,028
2
0
I'm trying to add some type of scripting capabilites to a big C++ project, and my boss told me to look into Python as an option. Niether one of us know much about, but it seems like I can either embed or extend it. Embedding can run Python, and extending can make calls to a dll.

What I need is the capability to run Python from an executable, and make calls to functions in the executable from Python.

Possible, or should I look somewhere else?
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
One simple way to run python, or anything else, is going to fork a process and run a python interpreter. On linux, look at system(). On Windows, look at spawn().
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
I can embed and run the interpreter fine from C++, but I can't find out how to make function calls back to the executable. On Windows btw.
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Originally posted by: tfinch2
Have you looked into SWIG? I think there is a Windows port.

Just quickly glancing at it, SWIG may do the trick. :thumbsup:

If not, I guess I'll be back. :p
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Well, SWIG still requires you to use a dll. :|

At this point, the only option I see is to embed python into the exe, then use sockets to talk back to it. Seems roundabout, but I'm out of ideas.