[Distutils] Dynamic linking on Linux, Mac OS, et al

Phillip J. Eby pje at telecommunity.com
Fri Jan 6 05:59:23 CET 2006


At 12:29 PM 1/6/2006 +0800, Jeff Pitman wrote:
>Are these just extensions that are imported? Because if they are, then you 
>don't need to mess with LD_LIBRARY_PATH and you can put them anywhere on 
>Linux as long as PYTHONPATH is correct. -- -jeff

Nope.  They're shared libraries being built by the distribution itself, as 
in the case of PyICU, and certain Windows C extensions that need to include 
the target library (e.g. sqlite) because it's not a "system" library there.

It could perhaps be questioned whether it's a good idea to include any 
other kind of shared library in an extension project, and in fact the 
common practice to link between Python extensions is to use a Python 
CObject to wrap an API function pointer table.  This neatly bypasses all of 
the issues...  *if* you control the library in question.

So far I've done a few experiments with trying to hack LD_LIBRARY_PATH at 
runtime, use dl.open() with RTLD_GLOBAL, etc. to force finding the right 
library, but so far it seems like there's no way to get the extensions to 
consider the opened library to be "the same" as the one they're looking 
for.  (Although it may just be that I'm missing some trick on the build 
side of the equation.)



More information about the Distutils-SIG mailing list