Skip to content

Commit 989c779

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 3ad66bf commit 989c779

6 files changed

Lines changed: 25 additions & 0 deletions

File tree

Doc/whatsnew/3.16.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ New features
7575
Other language changes
7676
======================
7777

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

7987

8088
New modules
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ const char *_PyImport_DynLoadFiletab[] = {
4747
#endif
4848
#ifndef Py_GIL_DISABLED
4949
".abi" PYTHON_ABI_STRING ".so",
50+
#ifdef SOABI_PLATFORM
51+
".abi" PYTHON_ABI_STRING "-" SOABI_PLATFORM ".so",
52+
#endif /* SOABI_PLATFORM */
5053
#endif /* Py_GIL_DISABLED */
5154
".abi" PYTHON_ABI_STRING "t.so",
55+
#ifdef SOABI_PLATFORM
56+
".abi" PYTHON_ABI_STRING "t-" SOABI_PLATFORM ".so",
57+
#endif /* SOABI_PLATFORM */
5258
".so",
5359
#endif /* __CYGWIN__ */
5460
NULL,

configure

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,8 @@ AS_CASE([$ac_sys_system],
12121212
[SOABI_PLATFORM=$PLATFORM_TRIPLET]
12131213
)
12141214

1215+
AC_DEFINE_UNQUOTED([SOABI_PLATFORM], ["${SOABI_PLATFORM}"], [Platform tag, used in binary module extension filenames.])
1216+
12151217
if test x$MULTIARCH != x; then
12161218
MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
12171219
fi

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,9 @@
18901890
/* The size of '_Bool', as computed by sizeof. */
18911891
#undef SIZEOF__BOOL
18921892

1893+
/* Platform tag, used in binary module extension filenames. */
1894+
#undef SOABI_PLATFORM
1895+
18931896
/* Define to 1 if you have the ANSI C header files. */
18941897
#undef STDC_HEADERS
18951898

0 commit comments

Comments
 (0)