[Distutils] swig 1.3.x

M.-A. Lemburg mal@lemburg.com
Fri Jan 3 06:45:02 2003


Keith Jackson wrote:
> I've run into a bit of a problem in getting swig 1.3.x working with
> distutils. Running swig on an interface file now produces two files
> by default; a python shadow class file and the C/C++ wrap file.
> 
> For example:
> swig -python example.i
> produces example_wrap.c and example.py.
> It then expects that the generated .so will be _example.so.
> 
> The problem is with the generated python file. How would we get it
> added into the python modules. It looks like build_py runs before
> build_ext, and even if they didn't there isn't a communication mechanism
> to have one Command sub-class add information into another Command 
> sub-class. Any thoughts about how this might be addressed?

There is: you have to reinitialize the command and then refinalize
it, e.g.

         # Reinitialize build_ext command with extra defines
         build_ext = self.distribution.reinitialize_command('build_ext')
         build_ext.ensure_finalized()

However, this doesn't rerun the command. That should be doable
with self.distribution.run_command('build_py') though.

> If this can be solved, everything else seems to be working fine. 
> Everything works fine for generating my modules since I don't use the 
> automated shadow class generation of swig. Getting this working for both 
> 1.1.x and 1.3.x required minimal changes to the build_ext class.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/