Skip to content

Commit 4926700

Browse files
committed
gh-122917 Allow stable API extensions to include a multiarch tuple in the filename
This permits stable ABI extensions for multiple architectures to be co-installed into the same directory, without clashing with each other, the same way (non-stable ABI) regular extensions can. It is listed below the current .abi3 suffix because setuptools will select the first suffix containing .abi3, as the target filename. We do this to protect older Python versions predating this patch.
1 parent 2520617 commit 4926700

5 files changed

Lines changed: 17 additions & 1 deletion

File tree

Doc/c-api/stable.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ On Windows, extensions that use the Stable ABI should be linked against
114114
``python39.dll``.
115115

116116
On some platforms, Python will look for and load shared library files named
117-
with the ``abi3`` tag (e.g. ``mymodule.abi3.so``).
117+
with the ``abi3`` tag (e.g. ``mymodule.abi3.so`` or
118+
``mymodule.abi3-x86-64-linux-gnu.so``).
118119
It does not check if such extensions conform to a Stable ABI.
119120
The user (or their packaging tools) need to ensure that, for example,
120121
extensions built with the 3.10+ Limited API are not installed for lower

Doc/whatsnew/3.15.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,15 @@ Other language changes
406406
making it a :term:`generic type`.
407407
(Contributed by James Hilton-Balfe in :gh:`128335`.)
408408

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

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,7 @@ Python/interpconfig.o: $(srcdir)/Python/interpconfig.c $(srcdir)/Python/config_c
19671967
Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
19681968
$(CC) -c $(PY_CORE_CFLAGS) \
19691969
-DSOABI='"$(SOABI)"' \
1970+
$(MULTIARCH_CPPFLAGS) \
19701971
-o $@ $(srcdir)/Python/dynload_shlib.c
19711972

19721973
Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Allow importing stable ABI C extensions that include a multiarch tuple
2+
in their filename, e.g. ``foo.abi3-x86-64-linux-gnu.so``.

Python/dynload_shlib.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const char *_PyImport_DynLoadFiletab[] = {
4545
"." ALT_SOABI ".so",
4646
#endif
4747
".abi" PYTHON_ABI_STRING ".so",
48+
#ifdef MULTIARCH
49+
".abi" PYTHON_ABI_STRING "-" MULTIARCH ".so",
50+
#endif
4851
".so",
4952
#endif /* __CYGWIN__ */
5053
NULL,

0 commit comments

Comments
 (0)