[Pythonmac-SIG] Linking against a Python extension
bob at redivi.com
Wed Dec 21 11:34:11 CET 2005
> bob at redivi.com schrieb am 20.12.2005 22:25:28:
>> > First question: Is it possible to link against a normally built Python
>> > extension?
>> > More specifically, I want to pass the '.so' file of some Python
>> > as an extra link argument to the 'weave.inline' function. This seems
>> > work quite well on Linux. But I suspect, on Mac OS X the answer is
>> > I just want this confirmed.
>> No. That's not the right way to do it anyway, you need to make a table
>> pointers available as a PyCObject or similar and get at it that way.
>> at how something like Numeric exports its interface.
> After some hours of googling, reading and blind trying I now (hopefully)
> understand why: On OS X a Python extension is not a "shared object" (in
> Linux sense) and not a dynamic library, but a (Mach-O) bundle, and a
> bundle is more similar to an executable file than to an object file. In
> particular: It cannot be input to the linker again. Dead end. Period.
Correct. I think it might be possible to use a MH_DYLIB as a Python
extension just by implementation detail, but distutils doesn't link that
way and you shouldn't. Using a table of function pointers is the only
right way to share C functionality between Python extensions, despite what
you're able to make work on one platform or another.
More information about the Pythonmac-SIG