[Python-Dev] Python modules should link to libpython

Ronald Oussoren ronaldoussoren at mac.com
Wed Feb 8 19:33:31 CET 2006


On 8-feb-2006, at 16:47, Gustavo J. A. M. Carneiro wrote:

> gjc:/usr/lib/python2.4/lib-dynload$ ldd itertools.so
>         libpthread.so.0 => /lib/libpthread.so.0 (0x00002aaaaabcc000)
>         libc.so.6 => /lib/libc.so.6 (0x00002aaaaace2000)
>         /lib/ld-linux-x86-64.so.2 (0x0000555555554000)
> gjc:/usr/lib/python2.4/lib-dynload$
>
> It seems that Python C extension modules are not linking explicitly to
> libpython.  Yet, they explicitly reference symbols defined in  
> libpython.
> When libpython is loaded in a global scope all is fine.  However, when
> libpython is dlopen()ed with the RTLD_LOCAL flag, python C extensions
> always get undefined symbols.
>
>   This problem happened recently with the nautilus-python package,  
> which
> installs an extension for the Nautilus file manager that allows
> extensions in Python.  For performance reasons, it now opens  
> extensions
> with RTLD_LOCAL flag, thus breaking python extensions.
>
>   Any thoughts?  Should I go ahead and open a bug report (maybe with
> patch), or is this controversial?

I don't know about Linux, but on OSX we don't link with libpython
(or Python.framework) on purpose: this allows you to share extensions  
between
several builds of the same version of Python. If you do link with  
libpython
and extension that was compiled by a python installed at a different  
location
will result in having two copies of libpython in memory, only one of  
which
is initialized. You end up with very interesting crashes.

Ronald

>
> -- 
> Gustavo J. A. M. Carneiro
> <gjc at inescporto.pt> <gustavo at users.sourceforge.net>
> The universe is always one step beyond logic.
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/ 
> ronaldoussoren%40mac.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2157 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20060208/918ae5ee/attachment.bin 


More information about the Python-Dev mailing list