This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients barry, dstufft, eric.araujo, lemburg, loewis, ncoghlan, piotr.dobrogost, pitrou, vstinner
Date 2019-04-25.00:42:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556152930.38.0.564528767422.issue21536@roundup.psfhosted.org>
In-reply-to
Content
I wrote PR 12946: "On Unix, C extensions are no longer linked to libpython".

Using PR 12946, the use case described in the initial message (msg218806) now works as expected. I can load a C extension built by a shared library Python with a statically linked Python:

$ LD_LIBRARY_PATH=/opt/py38shared/lib /opt/py38notshared/bin/python3.8
Python 3.8.0a3+ (heads/master:be0099719c, Apr 25 2019, 02:10:57) 
>>> import sys; sys.path.insert(0, '/opt/py38shared/lib/python3.8/lib-dynload')
>>> import _ssl
>>> _ssl
<module '_ssl' from '/opt/py38shared/lib/python3.8/lib-dynload/_ssl.cpython-38-x86_64-linux-gnu.so'>

/opt/py38notshared/bin/python3.8 is statically linked, whereas /opt/py38shared/lib/python3.8/lib-dynload/_ssl.cpython-38-x86_64-linux-gnu.so comes from a shared library Python.

Install shared libray Python into /opt/py38shared:

git clean -fdx; ./configure CFLAGS="-O0" --enable-shared --prefix /opt/py38shared && make && make install

Install statically linked Python into /opt/py38notshared:

git clean -fdx; ./configure CFLAGS="-O0" --prefix /opt/py38notshared && make && make install

--

As Antoine said, the opposite already works. Just in case, I also tested and I confirm that it still works:

$ LD_LIBRARY_PATH=/opt/py38shared/lib /opt/py38shared/bin/python3.8
Python 3.8.0a3+ (heads/master:be0099719c, Apr 25 2019, 02:09:02) 
>>> import sys; sys.path.insert(0, '/opt/py38notshared/lib/python3.8/lib-dynload')
>>> import _ssl
>>> _ssl
<module '_ssl' from '/opt/py38notshared/lib/python3.8/lib-dynload/_ssl.cpython-38-x86_64-linux-gnu.so'>

_ssl comes from statically linked Python (/opt/py38notshared) and is loaded in shared library Python (/opt/py38shared).
History
Date User Action Args
2019-04-25 00:42:10vstinnersetrecipients: + vstinner, lemburg, loewis, barry, ncoghlan, pitrou, eric.araujo, piotr.dobrogost, dstufft
2019-04-25 00:42:10vstinnersetmessageid: <1556152930.38.0.564528767422.issue21536@roundup.psfhosted.org>
2019-04-25 00:42:10vstinnerlinkissue21536 messages
2019-04-25 00:42:10vstinnercreate