Skip to content

Commit bcfc1fd

Browse files
committed
pythongh-122931 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 0fa144b commit bcfc1fd

6 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎Doc/whatsnew/3.16.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ Other language changes
8181
they reference) alive indefinitely.
8282
(Contributed by Łukasz Langa in :gh:`102960`.)
8383

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

8594
New modules
8695
===========
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
@@ -1938,6 +1938,9 @@
19381938
/* The size of '_Bool', as computed by sizeof. */
19391939
#undef SIZEOF__BOOL
19401940

1941+
/* Platform tag, used in binary module extension filenames. */
1942+
#undef SOABI_PLATFORM
1943+
19411944
/* Define to 1 if you have the ANSI C header files. */
19421945
#undef STDC_HEADERS
19431946

0 commit comments

Comments
 (0)