On 21/01/11 15:59, Asbach, Mark wrote:
> Hi Swig-Users,
> in case this is a frequently asked question, feel free to directly point me to existing documentation. Skimming the online manual (the following references mean 1.3 docs, but 2.0 seems to have no other information on these topics), I just didn't find it answered right away.
> What I would want to do is to wrap a package of multiple modules, all relying on some core module. This modules should share typemaps (and therefore Python types) from the core module and ideally they should share SWIG runtime methods, all linking to a shared module.
> The hypothetical package would look like
> __init__.py<- hand written, just some import statements
> core.i<- typemaps and infrastructure for all base classes
> core.py<- containing all base classes
> _core.so<- containing all base classes and ideally SWIG machinery
> methods_1.i<- starting with %import "core.i"
> methods_1.py<- providing additional methods on types from core.py
> _methods_1.so<- ideally sharing code from _core.so like SWIG_doblabla() helper methods
> methods_N.i<- starting with %import "core.i"
> _methods_N.so<- N might be in the range of 10 or 20, so I'd like to reuse as much as possible from _core.so
> I see that I can tell SWIG to generate import statements to handle the path correctly (section 30.11) like
> %module(package="huge") core
> Also, I see that I can import SWIG interfaces "without generating code" (section 7.2)
> %import "core.i"
> However, I would want to re-use the SWIG runtime code compiled into _core.so in every other module of the package.
> In old SWIG versions, there was an external shared library that one could use for keeping the runtime code concentrated in one place. Of course this had numerous drawbacks so I understand the motivation of "hiding" the SWIG runtime as static methods compiled into every module (section 15.2).
> Any advice on this would be appreciated ;-)
I havn't used this myself, but have you looked at the -external-runtime
option? Docs in http://www.swig.org/Doc2.0/Modules.html.