[Distutils] linking modules to a shared library
Bob Ippolito
bob at redivi.com
Mon Oct 3 21:15:24 CEST 2005
On Oct 3, 2005, at 10:56 AM, Stephen Langer wrote:
>>> Is it possible to create libBase portably with distutils? It's
>>> possible to do it on Linux by subclassing build_ext.build_ext and
>>> explicitly using self.compiler.compile() and
>>> self.compiler.link_shared_lib() to build the shared library before
>>> calling build_ext.build_ext.build_extensions(). But the same thing
>>> on Mac OS X only creates libBase.so, whereas I need it to create
>>> libBase.dylib.
>>>
>>>
>>
>> I don't know if this is possible, although I'd guess it is not.
>>
>
> That's too bad. Is there a reason for it? I'd volunteer to work on
> modifying distutils so that it can build a .dylib, but I am not an
> expert on library formats. I don't really know the difference
> between a .so and a .dylib, except that one of them works and the
> other doesn't. Can someone point me in the direction of a good
> reference on the topic?
The most portable way is to not build a libBase at all. Build a
Python extension that has all the functionality from libBase
available in it as a data structure with function pointers, and get a
reference to that from everything that depends on libBase
functionality. Take a look at what Numeric's C API does, for example.
-bob
More information about the Distutils-SIG
mailing list