Uh oh!
There was an error while loading. Please reload this page.
gh-122931: Include multiarch tuple in abi3t filenames - #122917
Conversation
5e380a1 to
7185a58Compare…ple 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.
7185a58 to
2955027Compare…ple 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.
2955027 to
c5b58a4Compare
vstinner
left a comment
There was a problem hiding this comment.
You should document this change in https://docs.python.org/dev/whatsnew/3.14.html (Doc/whatsnew/3.14.rst). I expect that you would elaborate a bit on the usage, how to use the feature, why it's needed, etc.
stefanor
commented
Aug 28, 2024
Done. FWIW, in Debian we plan to backport this to 3.13 too. |
vstinner
commented
Aug 29, 2024
I'm only aware of Debian who uses "multiarch". Do other operating systems also use it? Maybe Debian variants, Ubuntu, and Ubuntu variants? This change will slow down any "import module". I don't recall if there is a cache for that or not. |
stefanor
commented
Aug 29, 2024
All Debian derivatives, yes. They typically don't deviate very much, when it comes to plumbing. |
stefanor
commented
Aug 29, 2024
What do you want to do about that? Is there a benchmark you'd like to see results for? I see a table of 5 entries (including NULL) increasing to 6. That is one extra item to search, when:
|
vstinner
commented
Sep 2, 2024
Example of command: strace output: Internally, when Python imports the If we add a new entry to the import suffix, it will add one fstat() syscall per import (at least, to import a package). We should consider the impact on performance if we decide to add this feature. |
freakboy3742
commented
Sep 2, 2024
FWIW: macOS, iOS and Android all use However, on iOS and Android, there's limited need to keep binary artefacts in the same folder, as any given executable can only have a single architecture's executables. In addition, in the case of iOS, the binaries need to be migrated to the Frameworks folder and named as Frameworks, so any "side-by-side" benefits would be lost. Any "other platform" executables need to be stripped out as part of the build process, at which point there's no naming conflict. macOS uses the multiarch config value, but the value is always "darwin", and the universal binary format exists to support multiple architectures in a single binary file. I guess it might be useful to be able to have x86_64 and ARM64 binaries side-by-side... but there's probably only a year or two left in the official supported life of x86_64, so I don't think adding this feature will ultimately be that helpful for the macOS use case. |
vstinner
commented
Sep 2, 2024
@stefanor: Did you consider to maintain this change as a downstream-only patch in Debian? If you would like to make it upstream, I would suggest making it optional, disabled by default, and add a configure option to enable it. That's how I added some Fedora specific changes, such as: |
stefanor
commented
Sep 3, 2024
Here are some benchmarks: There is no discernable performance difference in minimal interpreter startup importtimeimportsysfromsubprocessimportcheck_callt1=time.perf_counter()
foriinrange(1000):
check_call([sys.executable, "-c", ""])
t2=time.perf_counter()
print((t2-t1) /1000)Looking at strace, I see only a single extra syscall. We can manufacture an import-intensive benchmark: importpkgutilimporttimet1=time.perf_counter()
formoduleinpkgutil.walk_packages(onerror=lambdapkg: None):
ifmodule.name.startswith("test."):
continueifmodule.name.endswith(".__main__"):
continueifmodule.namein {"antigravity", "idlelib.idle", "this", "zen"}:
continuetry:
__import__(module)
exceptException:
passt2=time.perf_counter()
print((t2-t1))Analysing this, I see 116 stat syscalls on |
stefanor
commented
Sep 3, 2024
Also, note that this is used on all linux platforms. The default for (non-stable ABI) extensions is to include the multiarch tuple in the extension filename. Pick a random binary wheel built in manylinux, and you'll see them.
I would be happy to do that. Although I prefer not carrying downstream-only patches long-term if possible. Look at the mess around Without this MR, there's no real point in supporting the multiarch tags in the non-stable ABI extensions. Either we get the benefit from doing it everywhere, or you say you don't need to support the feature, and we rip it out everywhere. We've got half a feature at the moment. Would you prefer it to all be behind a config argument?
These are not entirely Fedora-specific. And that's a good argument for always trying to upstream.
In Debian we use those paths for our cross-compilers. I imagine there is a scenario where it's useful to have Python headers in there.
We're a happy customer of this too, It meant one less patch to carry. |
stefanor
commented
Sep 4, 2024
vstinner
commented
Sep 18, 2024
@erlend-aasland@encukou: Would you mind to have a look at this issue? What do you think? Should it become the default behavior, or should it be a configure option? |
encukou
commented
Sep 23, 2024
IMO, the most important thing here is to keep this in mind for |
stefanor
commented
Sep 24, 2024
Yeah, that sounds sensible.
Is that expected? We've been on abi3 for quite a while. |
stefanor
commented
Sep 24, 2024
If we want that for the stable ABI, do we want to do the same thing for the regular ABI? It would probably affect a lot of build systems that assume they can name their output |
encukou
commented
Sep 24, 2024
Yes, over a decade. abi3 showing its age, and since it's incompatible free-threading we'll need a new alternative soon.
I don't see much reason to deprecate and remove that, so that we don't break the build systems you mention. (Note that even abi3/abi4 extensions will work with a bare |
stefanor
commented
Oct 7, 2024
I'm going to include it in our 3.13.0 upload. |
🔔 (I'd like to remind people to please consider this) |
vstinner
commented
Jun 26, 2026
Again, that's why I think that a discussion on discuss.python.org would be better (to coordinate). Maybe in the Packaging category. |
…uple in the filename This permits `abi3` 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 .abi3 suffix because .abi3 extensions are only compatible with future Python releases, not older versions. This follows on from python#122917 which was reduced down to just targetting `abi3t`
stefanor
commented
Jun 27, 2026
Now that this PR is just renaming |
…ple 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.
67e2548 to
238f194Compare…ple 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.
238f194 to
b4a6389Comparestefanor
commented
Jul 18, 2026
Updated to reflect the SC request for both |
| @@ -0,0 +1 @@ | |||
| Linux: Include multiarch tuples in ``abi3t`` stable ABI C extension filenames, e.g. ``foo.abi3t-x86-64-linux-gnu.so``, by default. | |||
There was a problem hiding this comment.
"Linux: ": this change doesn't seem to be specific to Linux, is it?
There was a problem hiding this comment.
Those tags won't exist on not-Linux
There was a problem hiding this comment.
Maybe we should change the text to say on platforms with multiarch tags (e.g. Linux).
There was a problem hiding this comment.
The current implementation doesn't work properly on FreeBSD, because the SOABI_PLATFORM macro is defined but it's defined to an empty string.
$ grep SOABI_PLATFORM pyconfig.h
#define SOABI_PLATFORM ""
In Python:
>>>importimportlib.machinery>>>importlib.machinery.EXTENSION_SUFFIXES
['.cpython-316d.so', '.cpython-316.so', '.abi3.so', '.abi3t-.so', '.abi3t.so', '.so']
>>>importsysconfig>>>SOABI_PLATFORM=sysconfig.get_config_var("SOABI_PLATFORM")
>>>SOABI_PLATFORM''Notice that '.abi3t-.so' is present in EXTENSION_SUFFIXES.
Possible fix:
diff --git a/configure.ac b/configure.ac
index 2d6672e3231..c30d98af28a 100644
--- a/configure.ac+++ b/configure.ac@@ -1212,7 +1212,9 @@ 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$SOABI_PLATFORM != x; then+ AC_DEFINE_UNQUOTED([SOABI_PLATFORM], ["${SOABI_PLATFORM}"], [Platform tag, used in binary module extension filenames.])+fi
if test x$MULTIARCH != x; then
MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""Add ALT_SOABI and SOABI_PLATFORM to test.pythoninfo. Add also EXTENSION_SUFFIXES of importlib.machinery.
vstinner
commented
Jul 18, 2026
I pushed a change in your branch to log ALT_SOABI, SOABI_PLATFORM and EXTENSION_SUFFIXES in test.pythoninfo. |
vstinner
commented
Jul 18, 2026
For example, I looked at the WASI job. Extracts of test.pythoninfo on WASI:
This changes adds |
vstinner
commented
Jul 18, 2026
pythoninfo on macOS: The PR adds pythoninfo on iOS: The PR adds |
stefanor
commented
Jul 18, 2026
Thanks for checking that Victor
Agreed that that's not what we want.
I don't know much about the WASI stack, but that's probably a reasonable thing to do if one is likely to have WASI builds near native builds. I'll add your configure change, it seems reasonable. |
stefanor
commented
Jul 18, 2026
FWIW, it looks like #152461 (which was originally stacked on top of this) may merge, including these changes and more. |
encukou
commented
Jul 27, 2026
Closing in favour of #152461 -- there's no need to merge the additions in two steps. |
stefanor
commented
Jul 28, 2026
Thank you for bringing that together! |



This permits
abi3tstable 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.