Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7961bbf

Browse filesBrowse files
stefanorencukouvstinner
authored
gh-122931: Allow stable abi3 API extensions to include a multiarch tuple in the filename (GH-152461)
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 before the current platform-less suffixes since it's more specific. The platform is stored in a new pyconfig.h define & sysconfig variable, SOABI_PLATFORM. On some known architectures (FreeBSD, Windows), this will be undefined/zero; these won't have the new tag (yet). Add SOABI_PLATFORM & ALT_SOABI the info to `make pythoninfo` as well. Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 58d9c78 commit 7961bbf
Copy full SHA for 7961bbf

9 files changed

+55Lines changed: 55 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Doc/whatsnew/3.15.rst‎

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.15.rst
+8Lines changed: 8 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,14 @@ Other language changes
873873
imports ``pkg.sub.mod``.
874874
(Contributed by Gregory P. Smith in :gh:`83065`.)
875875

876+
* File names of Stable ABI extensions that use the ``.so`` suffix may now
877+
include a multiarch tuple, for example, ``foo.abi3-x86-64-linux-gnu.so``.
878+
This permits stable ABI extensions for multiple architectures to be
879+
co-installed into the same directory, without clashing with each
880+
other, as regular dynamic extensions do.
881+
(Contributed by Stefano Rivera in :gh:`122931`.)
882+
883+
876884

877885
Default interactive shell
878886
=========================
Collapse file

‎Lib/test/pythoninfo.py‎

Copy file name to clipboardExpand all lines: Lib/test/pythoninfo.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ def collect_sysconfig(info_add):
570570

571571
for name in (
572572
'ABIFLAGS',
573+
'ALT_SOABI',
573574
'ANDROID_API_LEVEL',
574575
'CC',
575576
'CCSHARED',
@@ -595,6 +596,7 @@ def collect_sysconfig(info_add):
595596
'Py_REMOTE_DEBUG',
596597
'SHELL',
597598
'SOABI',
599+
'SOABI_PLATFORM',
598600
'TEST_MODULES',
599601
'VAPTH',
600602
'abs_builddir',
@@ -1315,6 +1317,12 @@ def collect_system(info_add):
13151317
info_add('system.hardware', hardware)
13161318

13171319

1320+
def collect_importlib(info_add):
1321+
import importlib.machinery
1322+
info_add('importlib.extension_suffixes',
1323+
importlib.machinery.EXTENSION_SUFFIXES)
1324+
1325+
13181326
def collect_info(info):
13191327
error = False
13201328
info_add = info.add
@@ -1357,6 +1365,7 @@ def collect_info(info):
13571365
collect_zstd,
13581366
collect_libregrtest_utils,
13591367
collect_system,
1368+
collect_importlib,
13601369

13611370
# Collecting from tests should be last as they have side effects.
13621371
collect_test_socket,
Collapse file

‎Lib/test/test_importlib/extension/test_finder.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_importlib/extension/test_finder.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import unittest
77
import sys
8+
import sysconfig
89

910

1011
class FinderTests(abc.FinderTests):
@@ -61,6 +62,7 @@ def test_failure(self):
6162

6263
def test_abi3_extension_suffixes(self):
6364
suffixes = self.machinery.EXTENSION_SUFFIXES
65+
platform = sysconfig.get_config_var("SOABI_PLATFORM")
6466
if 'win32' in sys.platform:
6567
# Either "_d.pyd" or ".pyd" must be in suffixes
6668
self.assertTrue({"_d.pyd", ".pyd"}.intersection(suffixes))
@@ -73,6 +75,13 @@ def test_abi3_extension_suffixes(self):
7375
self.assertIn(".abi3.so", suffixes)
7476
self.assertIn(".abi3t.so", suffixes)
7577

78+
if platform:
79+
if Py_GIL_DISABLED:
80+
self.assertNotIn(f".abi3-{platform}.so", suffixes)
81+
else:
82+
self.assertIn(f".abi3-{platform}.so", suffixes)
83+
self.assertIn(f".abi3t-{platform}.so", suffixes)
84+
7685

7786
(Frozen_FinderTests,
7887
Source_FinderTests
Collapse file

‎Lib/test/test_sysconfig.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_sysconfig.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,15 @@ def test_soabi(self):
457457
soabi = sysconfig.get_config_var('SOABI')
458458
self.assertIn(soabi, _imp.extension_suffixes()[0])
459459

460+
@unittest.skipIf(not _imp.extension_suffixes(), "stub loader has no suffixes")
461+
@unittest.skipIf(sys.platform == "win32", "Does not apply to Windows")
462+
@unittest.skipIf(sysconfig.get_config_var('SOABI_PLATFORM') == 0,
463+
"SOABI_PLATFORM is undefined")
464+
def test_soabi_platform(self):
465+
soabi_platform = sysconfig.get_config_var('SOABI_PLATFORM')
466+
soabi = sysconfig.get_config_var('SOABI')
467+
self.assertIn(soabi_platform, soabi)
468+
460469
def test_library(self):
461470
library = sysconfig.get_config_var('LIBRARY')
462471
ldlibrary = sysconfig.get_config_var('LDLIBRARY')
Collapse file
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow importing stable ABI C extensions that include a multiarch tuple in their filename, e.g. ``foo.abi3-x86-64-linux-gnu.so``.
Collapse file

‎Python/dynload_shlib.c‎

Copy file name to clipboardExpand all lines: Python/dynload_shlib.c
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ const char *_PyImport_DynLoadFiletab[] = {
4646
"." ALT_SOABI ".so",
4747
#endif
4848
#ifndef Py_GIL_DISABLED
49+
#ifdef SOABI_PLATFORM
50+
".abi" PYTHON_ABI_STRING "-" SOABI_PLATFORM ".so",
51+
#endif /* SOABI_PLATFORM */
4952
".abi" PYTHON_ABI_STRING ".so",
5053
#endif /* Py_GIL_DISABLED */
54+
#ifdef SOABI_PLATFORM
55+
".abi" PYTHON_ABI_STRING "t-" SOABI_PLATFORM ".so",
56+
#endif /* SOABI_PLATFORM */
5157
".abi" PYTHON_ABI_STRING "t.so",
5258
".so",
5359
#endif /* __CYGWIN__ */
Collapse file

‎configure‎

Copy file name to clipboardExpand all lines: configure
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎configure.ac‎

Copy file name to clipboardExpand all lines: configure.ac
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,10 @@ AS_CASE([$ac_sys_system],
12211221
[SOABI_PLATFORM=$PLATFORM_TRIPLET]
12221222
)
12231223

1224+
if test x$SOABI_PLATFORM != x; then
1225+
AC_DEFINE_UNQUOTED([SOABI_PLATFORM], ["${SOABI_PLATFORM}"], [Platform tag, used in binary module extension filenames.])
1226+
fi
1227+
12241228
if test x$MULTIARCH != x; then
12251229
MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
12261230
fi
Collapse file

‎pyconfig.h.in‎

Copy file name to clipboardExpand all lines: pyconfig.h.in
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,9 @@
19681968
/* The size of '_Bool', as computed by sizeof. */
19691969
#undef SIZEOF__BOOL
19701970

1971+
/* Platform tag, used in binary module extension filenames. */
1972+
#undef SOABI_PLATFORM
1973+
19711974
/* Define to 1 if you have the ANSI C header files. */
19721975
#undef STDC_HEADERS
19731976

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.