[Pythonmac-SIG] Loading modules on MacOS

jurem@flextronics.si jurem at flextronics.si
Sun Oct 30 08:06:10 CET 2005


Hi all,
I'm porting some software from Linux/Python to MacOS/Python. Core modules
are written in C++ and are loaded in Python as modules.

On Linux those core modules are linked as shared libraries (.so). It looks
something like:

core_module1.so <-- 'standalone' core module, does not link any other lib
high_module2.so <-- higher level module which is using core_module1.so

Problem on MacOS is, that Python modules are bundles not shared libraries,
so I've made it like:

core_module1.dylib <-- dynamic library (using -dynamiclib gcc option)
core_module1.so    <-- bundle, created from .dylib
high_module2.so    <-- bundle, which also links .dylib

I'm symlinking core_module1.dylib to libcore_module1.dylib.
Link options for both bundles are:
-W1,-F. -bundle -framework Python -lstdc++ -L. -lcore_module1

If I create only core_module1.so (as bundle, without dynamic library) it
loads properly, but if I do it this way Python 'hangs' when I try to load
module. I'm using dlcompat library (Mach-O wrapper) for loading dynamic
library (dlopen, dlysm, ...) and it should work fine.

Python version is 2.3, GCC is 3.3 (if I try to compile it on Linux with
same versions works without problems)

Does anyone have any idea, what could be wrong? I think this would be the
cleanest way to port this software, am I wrong?

Thanks for any ideas/suggestions,

regards, Jure



More information about the Pythonmac-SIG mailing list