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

Torsten Bronger bronger at physik.rwth-aachen.de
Sun Feb 20 23:25:57 CET 2005


Hallöchen!

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.)

A solution without the necessaty of calling twice and without errors
is

setup(name = 'my',
      py_modules = ['my'],
      ext_modules = [Extension('_mymodule',
                               sources = ['mymodule.c',
                                          'mymodule.i'])]
)
setup(name = 'mymodule',
      py_modules = ['mymodule'],
)

I.e., calling "setup" twice in the same setup.py.  But is this
really the clean solution for this problem?

Thank you!

Tschö,
Torsten Bronger.

-- 
Torsten Bronger, aquisgrana, europa vetus



More information about the Distutils-SIG mailing list