distutils with swig support
Hi, Some of my Python packages that build swigged code need to run swig with include directories and/or with macro definitions. The standard Python distutils does not provide this as an option, so I ended up with two sub-classes of the distutils package that I distribute along with the setup script. I consider it more a hack, but my colleagues keep telling me, I should let you know, so that it might be considered for a future distutils version or that it is at least available to the community. Below is an attachment including an alternative distribution class for distutils that applies the --include-dirs and --define options of the build_ext command not only to the compiler but also to swig. The include_dirs and define_macros keywords in the setup call are considered as well. Usually the Python support file from swig is left unused in the src directory. The alternative distribution class also puts the Python output of swig to the build/lib.machine/package directory, so that it gets installed. Here are a few lines of a setup.py script that uses the alternative distribution class. The two files dist_with_swig.py and build_ext_with_swig.py live in the same directory than setup.py. # import setup tools from distutils.core import setup, Extension # import distribution class with swig support from dist_with_swig import Distribution_with_swig # set up package setup(distclass=Distribution_with_swig, name="my_package", ...) Happy swigging, Christian P.S. I used distutils version 1.0.3 of Python 2.3.3 to sub-class. In the attachment are also the patches for dist.py and build_ext.py.
participants (1)
-
Christian Dieterich