I have a Python module with nothing but regular global functions. I need to call it from another business-domain scripting environment that can only call out to C DLLs. Is there anyway to build my Python modules so that to other code it can be called like a standard C function that's exported from a DLL? This is for a Windows environment. I'm aware of IronPython, but as far as I know it can only build .NET Assemblies, which are not callable as C DLL functions.
+5
A:
Take a look at this Codeproject article. One way would be wrap your python functions in a C dll and expose this to the callee.
COM is a binary protocol to solve this issue. But you will have to wrap this python dll in a COM wrapper. And add some code on the calling side as well.
dirkgently
2009-03-14 13:24:45
+3
A:
The standard solution is to embed the Python interpreter (which is already a C DLL) in your application.
S.Lott
2009-03-14 13:41:54
+1: the simplest way
J.F. Sebastian
2009-03-15 18:56:42
+2
A:
Py2exe can generate COM dlls from python code, by compiling and embedding python code + interpreter. It does not, AFAIK, support regular DLLs yet. For that, see dirkgently's answer about embedding python yourself.
Marcus Lindblom
2009-03-14 13:49:25