don't embed Python code into libwallycore.so
#501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Embedding SWIG Python code into
libwallycore.so
ties the library to a specific version of Python, thereby precluding concurrent installation of thewallycore
Python module for multiple implementations of Python on the same system if the Python modules are linked with a system-widelibwallycore.so
. On Gentoo at least, linkinglibwallycore.so
withlibpython3.14.so
and then attempting to use thewallycore
Python module from Python 3.11, 3.12, or 3.13 causes an immediate segfault.Rather than injecting Python-specific glue into
libwallycore.so
, we can and should keep it contained within the Python native extension library that we build for each Python implementation. The Python wheel actually already compilesswig_python_wrap.c
and links it into the native extension library, so linking it intolibwallycore.so
as well is redundant and harmful.Remove
libswig_python.la
fromlibwallycore_la_LIBADD
, and expunge its existence fromMakefile.am
entirely since it's now unused.The Python wheel build for each Python implementation compiles
swig_python_wrap.c
against the headers for that particular Python implementation, ensuring that the resulting native extension library matches the ABI of the Python implementation for which it is installed. This may be a different Python implementation than the one found by Autoconf, the only relevance of which now is in finding the interpreter with which to run the tests.Since we no longer link
libwallycore.so
withlibpython*.so
, there should no longer be any manylinux compatibility issues, so drop the--enable-python-manylinux
Autoconf option and thePYTHON_MANYLINUX
Automake conditional. This also means that the test programs no longer need to link with$(PYTHON_LIBS)
sincelibwallycore.la
now never has any dependence on Python (implicit or explicit).Note that the Python native extension libraries do not explicitly link with
libpython*.so
either. This is correct, as the dynamic linker resolves their undefinedPy*
symbols when it loads them into the Python interpreter.After applying these changes, the Gentoo ebuild for libwally-core 1.5.0 now successfully runs the SWIG Python tests on all currently supported versions of Python (3.11 through 3.14), all using the same
libwallycore.so.6
.For reference, this is a follow-up to a comment I made back in November 2023:
That bad feeling has indeed blossomed into an actual segfault as of Python 3.14.
At that same time, @jgriffiths noted: