swig win32 scons

myheartinamerica myheartinamerica at gmail.com
Mon Apr 16 13:11:18 EDT 2007


Hello,

I spent the morning figuring out how to use SWIG on Microsoft Windows.
I compiled the example from the SWIG tutorial on http://www.swig.org.
The biggest stumbling block was not knowing that I needed to rename
the DLL created to have a PYD extension. I also ended up writing
a .def file for exporting functions from the DLL.

Here is my SConstruct file for using SCons to build the library. It is
not perfect, but it should be evident as to what I was doing. I hope
that others will be able to find this in the future and save
themselves some time.:


##############################
SWIG_EXE = r'C:\Python25\swig\swig.exe'


env = Environment(SWIG=SWIG_EXE,
                  SWIGFLAGS=['-python'],
                  CPPPATH=[r'C:\Python25\include'],
                  LIBPATH=[r'C:\Python25\libs'])
swigObject = env.SharedObject(['example.i'])
copyToPYD = Copy('_example.pyd', '_example.dll')
env.AddPostAction('_example.dll', copyToPYD)
env.SharedLibrary('_example.dll', ['example.c', swigObject])




More information about the Python-list mailing list