From: David F. <dav...@gm...> - 2012-06-12 21:20:44
|
Hi, What about renaming the extension '_state' -> 'grlib.automaton._state' ? Like this: Extension('grlib.automaton._state', ['grlib/automaton/state/state.i'], depends = ['grlib/automaton/state/state.h', 'grlib/automaton/state/state.c'], swig_opts = ['-py3'])) Documented in: (class distutils.core.Extension, argument name) http://docs.python.org/distutils/apiref.html Regards, David On Tue, 12 Jun 2012 12:41:31 +0200, Simon Busard <sim...@uc...> wrote: > Hello, > > I'm trying to build a Python wrapper for a large program using SWIG. > This program is divided into packages, one directory per package. > > To build the wrapper, I created and filled a SWIG interface (.i file) > for each package, including header files of the packages. I created the > shared library by hand and I use distutils to build one extension for > each Python package corresponding to program packages. > > My problem lies in the fact that there are some program sub-packages > that have the same name, but they lie in different directories. When > using distutils to build the extensions, the SWIG documentation tells to > build extensions in place (by using --inplace option of setup.py > build_ext). The problem is the following: when building extensions, .so > files are built in the current directory, and packages with the same > names lead to .so files with the same name, leading to a conflict. > > Here after is a little example illustrating my problem. > > I have a library grlib, with two packages "automaton" and "graph". In > these two packages are two sub-packages named "state". In these packages > lie the headers and .c files. > > grlib/ > automaton/ > state/ > state.h > state.c > state.i > graph/ > state/ > state.h > state.c > state.i > > grlib/automaton/state/state.i contains > > %module(package="grlib.automaton.state") state > > %{ > #include "state.h" > %} > > %include state.h > > and the other SWIG interface is similar. > > My setup.py file contains, for each package, an extension: > > Extension('_state', ['grlib/automaton/state/state.i'], > depends = ['grlib/automaton/state/state.h', > 'grlib/automaton/state/state.c'], > swig_opts = ['-py3'])) > > When building extensions using "python setup.py build_ext --inplace", > the script creates one _state.so file at the root directory. This file > is used when importing the Python module in the Python interpreter (for > example). > > To summarize, my problem lies in the fact that there are two submodules > that have the same name. Do you have any idea how I can fix this > problem? I want to avoid renaming the modules since I want to be able to > use it in python with "import grlib.automaton.state" for example. > > > Thank you very much for your help in advance, > > Regards, > > Simon Busard > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user |