diff --git a/Doc/c-api/stable.rst b/Doc/c-api/stable.rst index 8fed4b69b25dd8..357e4a4eccb9c4 100644 --- a/Doc/c-api/stable.rst +++ b/Doc/c-api/stable.rst @@ -114,7 +114,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.15.rst b/Doc/whatsnew/3.15.rst index 40286d4fe857e8..f8e84f0e3ddba0 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -284,6 +284,14 @@ Other language changes not only integers or floats, although this does not improve precision. (Contributed by Serhiy Storchaka in :gh:`67795`.) +* 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`.) New modules =========== diff --git a/Makefile.pre.in b/Makefile.pre.in index 19423c11545c19..b12641b028f893 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1958,6 +1958,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,