diff --git a/Lib/test/test_importlib/extension/test_finder.py b/Lib/test/test_importlib/extension/test_finder.py index dc77fa78a203fdb..c460ff01d9f0d26 100644 --- a/Lib/test/test_importlib/extension/test_finder.py +++ b/Lib/test/test_importlib/extension/test_finder.py @@ -5,6 +5,7 @@ import unittest import sys +import sysconfig class FinderTests(abc.FinderTests): @@ -61,6 +62,7 @@ def test_failure(self): def test_abi3_extension_suffixes(self): suffixes = self.machinery.EXTENSION_SUFFIXES + platform = sysconfig.get_config_var("SOABI_PLATFORM") if 'win32' in sys.platform: # Either "_d.pyd" or ".pyd" must be in suffixes self.assertTrue({"_d.pyd", ".pyd"}.intersection(suffixes)) @@ -71,7 +73,10 @@ def test_abi3_extension_suffixes(self): self.assertNotIn(".abi3.so", suffixes) else: self.assertIn(".abi3.so", suffixes) - self.assertIn(".abi3t.so", suffixes) + if platform: + self.assertIn(f".abi3t-{platform}.so", suffixes) + else: + self.assertIn(".abi3t.so", suffixes) (Frozen_FinderTests, diff --git a/Misc/NEWS.d/next/C_API/2024-08-12-09-48-04.gh-issue-122931.QwHc2l.rst b/Misc/NEWS.d/next/C_API/2024-08-12-09-48-04.gh-issue-122931.QwHc2l.rst new file mode 100644 index 000000000000000..734547c86dbfbda --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2024-08-12-09-48-04.gh-issue-122931.QwHc2l.rst @@ -0,0 +1 @@ +Linux: Include multiarch tuples in ``abi3t`` stable ABI C extension filenames, e.g. ``foo.abi3t-x86-64-linux-gnu.so``. diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 0ff88ad330fd09c..a60cd1850c7df14 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -48,7 +48,11 @@ const char *_PyImport_DynLoadFiletab[] = { #ifndef Py_GIL_DISABLED ".abi" PYTHON_ABI_STRING ".so", #endif /* Py_GIL_DISABLED */ +#ifdef SOABI_PLATFORM + ".abi" PYTHON_ABI_STRING "t-" SOABI_PLATFORM ".so", +#else ".abi" PYTHON_ABI_STRING "t.so", +#endif /* SOABI_PLATFORM */ ".so", #endif /* __CYGWIN__ */ NULL, diff --git a/configure b/configure index e96b87989793a8f..0dc65b339c97611 100755 --- a/configure +++ b/configure @@ -7266,6 +7266,10 @@ case $ac_sys_system in #( ;; esac + +printf "%s\n" "#define SOABI_PLATFORM \"${SOABI_PLATFORM}\"" >>confdefs.h + + if test x$MULTIARCH != x; then MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" fi diff --git a/configure.ac b/configure.ac index cd1883f0195c47e..c803c3b9ab8e208 100644 --- a/configure.ac +++ b/configure.ac @@ -1212,6 +1212,8 @@ AS_CASE([$ac_sys_system], [SOABI_PLATFORM=$PLATFORM_TRIPLET] ) +AC_DEFINE_UNQUOTED([SOABI_PLATFORM], ["${SOABI_PLATFORM}"], [Platform tag, used in binary module extension filenames.]) + if test x$MULTIARCH != x; then MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" fi diff --git a/pyconfig.h.in b/pyconfig.h.in index a05cd8ecc91e197..b2d343735e87ce6 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1890,6 +1890,9 @@ /* The size of '_Bool', as computed by sizeof. */ #undef SIZEOF__BOOL +/* Platform tag, used in binary module extension filenames. */ +#undef SOABI_PLATFORM + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS