Newb, using Python in win32 app, how to import c++ modules created with swig from an .exe

Jon Moldover moldover at yahoo.com
Tue Oct 28 18:34:09 EST 2003


Hi, I'm using Python in my win32 app by linking to the python23.dll. 
I'm trying to expose some c++ code in my app to Python so I can make
application calls from Python scripts (according to the Python windows
FAQ I shouldn't have to make a seperate dll, see link below).  I
create a MyModule.i file for swig which contains a simple test c++
class.  I run swig on it with the following options: swig -python -c++
-includeall -shadow MyModule.i, and as expected it creates a
MyModule.py and MyModule_wrap.cxx.  When I can compile the .cxx
wrapper file into my app, my app now exports init_MyModule.  This
seems good.  The problem is, how do I import this module into Python? 
If I run the MyModule.py script swig generated, it tries to import the
swig-generated shadow class module named _MyModule, which in turn
looks for a lib named _MyModule.lib and dll named _MyModule.pyd, which
don't exist.  I need to point Python to the code in my application
(which is named MyApp.exe).  I'm guessing there might be a swig option
which does this, but I can't find it in the documentation.  For
reference I've included a link to the relevant part of the Python
Windows faq below.  Much thanks for any help.

 - Jon Moldover
Frog City Sofware
flair at frogcity.com

http://www.python.org/doc/faq/windows.html#how-can-i-embed-python-into-a-windows-application




More information about the Python-list mailing list