[New-bugs-announce] [issue21536] extension built with a shared python cannot be loaded with a static python

Antoine Pitrou report at bugs.python.org
Mon May 19 20:50:02 CEST 2014


New submission from Antoine Pitrou:

When a C extension is built (using distutils) with a shared library Python, it cannot be loaded with an otherwise identical statically linked Python. The other way round works fine. Trivial example using the _ssl module:

>>> import sys
>>> sys.path.insert(0, '/home/antoine/cpython/shared/build/lib.linux-x86_64-3.5/')
>>> import _ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory

This is probably because of an additional -L flag that is passed when linking a C extension with a shared library Python. I don't think the flag is useful under Linux (or perhaps under any other OS at all), since the relevant symbols are already loaded when the interpreter tries to load the C extension.

(AFAIK, systems notorious for providing shared library Pythons are RedHat-alike systems, while Debian/Ubuntu provide statically linked Pythons)

----------
components: Library (Lib)
messages: 218806
nosy: dstufft, eric.araujo, loewis, ncoghlan, pitrou
priority: normal
severity: normal
status: open
title: extension built with a shared python cannot be loaded with a static python
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21536>
_______________________________________


More information about the New-bugs-announce mailing list