I have several compiled python modules; they are put into a single .so (to avoid runtime linking, there are cross-module symbol dependencies), but a number of symlinks points to this .so:
foo.so -> liball.so
bar.so -> liball.so
liball.so
This way, I can do import foo (Python will call initfoo() defined in liball.so) or import bar (calls initbar()).
I am wondering if this approach will work on Windows?
Probably not, but you could achieve your goal with
if you need to import them at several places, or with
if you need that only at one place.
It might be, however, that the distinction between
initfoo()andinitbar()cannot be held and that both must be done so that the module effectively contains everything to be contained in both modules.If
foopartially contains the same symbols asbar, but with a different meaning, this approach won’t work. But then you can just copy the file. This will occupy more disk space than needed, but that doesn’t hurt so much, IMHO.