[Distutils] SWIG: two modules, but only one can be installed

Lars Immisch lars at ibp.de
Sun Feb 20 23:46:44 CET 2005


> I have a module here that makes a library available to python using
> SWIG.  The setup.py file looks like this:
> 
> setup(name = 'my',
>       py_modules = ['mymodule','my'],
>       ext_modules = [Extension('_mymodule',
>                                sources = ['mymodule.c',
>                                           'mymodule.i'])]
> )
> 
> Unfortunately, SWIG creates not only "_mymodule" but also
> "mymodule".  However, the above script must be called twice, because
> at the first run, "mymodule" doesn't exist yet.  (This is
> accompanied by error messages, by the way.)

This problem can probably solved with SWIG alone. Do look into the 
%pythoncode directive.

Briefly, off the top of my head:

include all code that you used to have in mymodule.py in a

%pythoncode %{
%}

section in mymodule.i.

- Lars


More information about the Distutils-SIG mailing list