Skip to content

Select the abi3 suffix matching the host GIL mode - #165

Open
MementoRC wants to merge 3 commits into
robotpy:mainfrom
MementoRC:abi3-suffix-gil-mode
Open

MementoRC wants to merge 3 commits into
robotpy:mainfrom
MementoRC:abi3-suffix-gil-mode

Conversation

@MementoRC

Copy link
Copy Markdown

1.6.0 added EXTENSION_SUFFIXES to importlib-machinery-patch so that setuptools get_abi3_suffix() stops picking the build interpreter's platform-tagged .abi3-<multiarch>.so on a cross build. The second element is hardcoded to ".abi3.so", which is correct only for a GIL-enabled host.

In Python/dynload_shlib.c the plain abi3 entries are inside the #ifndef Py_GIL_DISABLED block while the abi3t entries are outside it, so a free-threaded interpreter has no plain .abi3 entry in its filetab at all. With the hardcoded list, a free-threaded cross build names the extension .abi3.so, which that interpreter cannot load.

This takes the suffix from the host's own Py_GIL_DISABLED instead. .get() rather than indexing, since the var is absent from a GIL build's build_time_vars rather than set to 0.

Measured on a GIL build, CPython 3.15.0rc2 x86_64, _imp.extension_suffixes():

['.cpython-315-x86_64-linux-gnu.so', '.abi3-x86_64-linux-gnu.so', '.abi3.so',
 '.abi3t-x86_64-linux-gnu.so', '.abi3t.so', '.so']

I have not tested a free-threaded cross build; this is from reading dynload_shlib.c and the host build_time_vars. Happy to adjust if you would rather list both forms than pick one - note that get_abi3_suffix() takes the first entry containing .abi3, and .abi3t.so matches that substring, so ordering would become load-bearing.

Raised by @isuruf in conda-forge/crossenv-feedstock#49.

Comment thread crossenv/__init__.py Outdated
# free-threaded build has only the ".abi3t" forms in its filetab.
# Pick the one the HOST interpreter can actually load.
if self.host_sysconfigdata.build_time_vars.get("Py_GIL_DISABLED"):
self.sysconfig_abi3_suffix = ".abi3t.so"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for 3.15+. For earlier versions there's no abi3.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so this calls for a version guard, a dedicated helper function?

EXTENSION_SUFFIXES = [
{{repr(self.sysconfig_ext_suffix)}},
{{repr(self.sysconfig_abi3_suffix)}},
".so",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are also missing abi3-x86_64-linux-gnu.so types coming in 3.15

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, abi-<arch>.so. Could try extracting from sysconfig_ext_suffix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the order correct?

        suffixes = [".%s.so" % stem]
        soabi_platform = self._host_soabi_platform()
        if soabi_platform:
            suffixes.append(".%s-%s.so" % (stem, soabi_platform))

@MementoRC MementoRC Sep 14, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test is passing: tests/test_environment.py::test_abi3_extension_suffixes PASSED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants