Skip to content

Commit ecb87b4

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 1c598e0 commit ecb87b4

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ Other language changes
284284
not only integers or floats, although this does not improve precision.
285285
(Contributed by Serhiy Storchaka in :gh:`67795`.)
286286

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

288296
New modules
289297
===========

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,7 @@ Python/interpconfig.o: $(srcdir)/Python/interpconfig.c $(srcdir)/Python/config_c
19581958
Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
19591959
$(CC) -c $(PY_CORE_CFLAGS) \
19601960
-DSOABI='"$(SOABI)"' \
1961+
$(MULTIARCH_CPPFLAGS) \
19611962
-o $@ $(srcdir)/Python/dynload_shlib.c
19621963

19631964
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)