Skip to content

gh-122931 Allow stable API extensions to include a multiarch tuple in the filename #122917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Doc/c-api/stable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ On Windows, extensions that use the Stable ABI should be linked against
``python39.dll``.

On some platforms, Python will look for and load shared library files named
with the ``abi3`` tag (e.g. ``mymodule.abi3.so``).
with the ``abi3`` tag (e.g. ``mymodule.abi3.so`` or
``mymodule.abi3-x86-64-linux-gnu.so``).
It does not check if such extensions conform to a Stable ABI.
The user (or their packaging tools) need to ensure that, for example,
extensions built with the 3.10+ Limited API are not installed for lower
Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,15 @@ Other language changes
The testbed can also be used to run the test suite of projects other than
CPython itself. (Contributed by Russell Keith-Magee in :gh:`127592`.)

* Stable ABI extensions may now include a multiarch tuple in the
filename, e.g. ``foo.abi3-x86-64-linux-gnu.so``.
This permits stable ABI extensions for multiple architectures to be
co-installed into the same directory, without clashing with each
other, as regular dynamic extensions do. Build tools will not generate
these multiarch tagged filenames, by default, while still supporting
older Python versions that don't recognize these filenames.
(Contributed by Stefano Rivera in :gh:`122931`.)

.. _whatsnew314-pep765:

PEP 765: Disallow return/break/continue that exit a finally block
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,7 @@ Python/interpconfig.o: $(srcdir)/Python/interpconfig.c $(srcdir)/Python/config_c
Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
$(CC) -c $(PY_CORE_CFLAGS) \
-DSOABI='"$(SOABI)"' \
$(MULTIARCH_CPPFLAGS) \
-o $@ $(srcdir)/Python/dynload_shlib.c

Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Allow importing stable ABI C extensions that include a multiarch tuple
in their filename, e.g. ``foo.abi3-x86-64-linux-gnu.so``.
3 changes: 3 additions & 0 deletions Python/dynload_shlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const char *_PyImport_DynLoadFiletab[] = {
"." ALT_SOABI ".so",
#endif
".abi" PYTHON_ABI_STRING ".so",
#ifdef MULTIARCH
".abi" PYTHON_ABI_STRING "-" MULTIARCH ".so",
#endif
".so",
#endif /* __CYGWIN__ */
NULL,
Expand Down
Loading