diff --git a/Doc/c-api/stable.rst b/Doc/c-api/stable.rst index 124e58cf950b7a..25727d9a550ea1 100644 --- a/Doc/c-api/stable.rst +++ b/Doc/c-api/stable.rst @@ -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 diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index a561d3b3383fc5..6f07d51ac80b8d 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -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 diff --git a/Makefile.pre.in b/Makefile.pre.in index 3ef0c6320c85db..5d5fe2f9448199 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -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 diff --git a/Misc/NEWS.d/next/C_API/2024-08-12-09-48-04.gh-issue-122931.QwHc2l.rst b/Misc/NEWS.d/next/C_API/2024-08-12-09-48-04.gh-issue-122931.QwHc2l.rst new file mode 100644 index 00000000000000..d1caad2e98482d --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2024-08-12-09-48-04.gh-issue-122931.QwHc2l.rst @@ -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``. diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 583c9b752dfd90..cc42818da04422 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -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,