Can I embed Windows Python in C# or VC++?

Christian Heimes lists at cheimes.de
Fri Dec 7 04:12:23 EST 2007


grbgooglefan wrote:
> I want to use Python's Windows (python25.dll) version to embed in my
> C# (or atleast VC++) program for performing syntax checks on the
> Python expressions which are later supposed to be evaluated at runtime
> by another C++ program
> 
> For this, I would like to use CPython API functions such as
> Py_Initialize, PyModule_New, PyModule_GetDict, PyRun_String,
> PyObject_GetAttrString, PyObject_CallObject, PyTuple_SetItem & other
> similar functions from my C#/ VC++ program on Windows.

It's not a matter of C++ or C## but a matter of managed or unmanaged
language. Nowadays VS C++ can create old style binaries and CLR. For C++
you can use  the MSI but I recommend a source installation. It makes
debugging easier. You may want to port my PCbuild9 directory from svn
trunk (Python 2.6) to Python 2.5 if you like to use VS 2008.

For CLR/.NET (Managed C++, C#, VB, ...) you need the PythonDotNET
bindings from http://pythonnet.sf.net/. Brian (the creator of
PythonDotNET) and I are very busy in the last weeks and months. The last
preview release is outdated. Please check out the latest version from
PythonDotNET's SVN.

The support for unmanaged C++ is better than the support for managed
.NET code.

Christian




More information about the Python-list mailing list