changing build order for SWIG extensions

timothy.williams at nvl.army.mil timothy.williams at nvl.army.mil
Wed May 25 09:31:57 EDT 2005


Hi all.


How do I tell distutils to run build_ext before build_py when I try to
do a

'python setup.py build' ?

I have a C extension using SWIG, and when I build with setup.py,
build_py runs on the current module.py file before swig
creates/recreates it. I got around it by just putting in another call
to setup for the py_module, but if I try to create a bdist, the second
call to setup  over writes the first w/o the _module.so file.

(bottom of setup.py)

# build extension module
setup (name = 'OTB_libs',
       version='1.0',
       author="Tim Williams",
       packages=['OTB_libs'],
       package_dir={'OTB_libs':''},
       ext_modules=[Extension('OTB_libs._OTB_libs',
                              sources=['OTB_libs.i'],
                              include_dirs=INCLDIRS,
                              library_dirs=LIBDIRS,
                              libraries=liblist,
                              extra_compile_args=['-malign-double'],
                              swig_opts=swig_opts
                              )
                    ]
       )

#this needs to be built after the extension is since OTB_libs.py is
#generated by SWIG
setup (name='OTB_libs',
       version='1.0',
       author="Tim Williams",
       py_modules=['OTB_libs.OTB_libs'],
       package_dir={'OTB_libs':''}
       )

Am I stuck with just calling running 'python setup.py build' twice?

Thanks for any help.




More information about the Python-list mailing list