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

J

Jon Moldover

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
(e-mail address removed)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top