Skip to content

Opaque PyObject ABI support#5807

Open
ngoldbaum wants to merge 215 commits into
PyO3:mainfrom
ngoldbaum:opaque-pyobject
Open

Opaque PyObject ABI support#5807
ngoldbaum wants to merge 215 commits into
PyO3:mainfrom
ngoldbaum:opaque-pyobject

Conversation

@ngoldbaum
Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum commented Feb 13, 2026

Fixes #5786.

  • Adds support for the new PEP 803 abi3t ABI.
    • Adds new abi3t and abi3t-py315 features to enable abi3t builds. These features work analogously to the abi3 features.
  • Adds a new target_abi field to the InterpreterConfig struct. This allows keeping track of a separate host and target Python version and fixing some longstanding issues with separation of concerns there.
  • Adds a PythonAbi and PythonAbiBuilder struct which wraps an implementation, version, and a new PythonAbiKind enum. The PythonAbiKind enum can itself be one of two enums: StableAbi or VersionSpecific. The former can be Abi3 or Abi3t and the latter can be FreeThreaded or GilEnabled. It's a lot of new types but it also allows us to track details about the target ABI in a much more fine-grained manner.

@ngoldbaum

This comment was marked as outdated.

@ngoldbaum

This comment was marked as outdated.

@ngoldbaum

This comment was marked as outdated.

@ngoldbaum

This comment was marked as outdated.

@Icxolu

This comment was marked as outdated.

@ngoldbaum

This comment was marked as outdated.

@ngoldbaum

This comment was marked as outdated.

@ngoldbaum

This comment was marked as outdated.

@davidhewitt

This comment was marked as outdated.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

Also I think we will need to update features.md and building-and-distribution.md in the guide to document the new features & behaviour.

I got to everything except for this today. See latest push.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

Argh, I think the Windows 3.15 builds might be hitting python/cpython#149786. I will try to reproduce.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I filed python/cpython#149887 for the Windows issue we're running into. I had run into it elsewhere but not fully understood the cause until now.

@davidhewitt how would you like to handle Windows GIL-enabled abi3t builds being broken for 3.15.0b1? Just turn off the build because it's an upstream bug? We could also work around it by installing Python from uv instead of setup-python, I think.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I added docs. I also disabled Windows abi3t build tests with a GIL-enabled interpreter in the noxfile along with a note to re-enabled when the upstream bug is fixed.

2. Ensure that the built shared objects are correctly marked as `abi3` and `abi3t`.
This is accomplished by telling your build system that you're using the limited API.
[`maturin`] >= 0.9.0 and [`setuptools-rust`] >= 0.11.4 support `abi3` wheels.
[`maturin`] >= 0.9.0 and [`setuptools-rust`] >= 0.11.4 support `abi3` wheels and [`maturin`] >= 1.14 supports `abi3t` wheels.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ping @messense, it probably makes sense to coordinate the release of PyO3 0.29 and a maturin release that supports abi3t.

Copy link
Copy Markdown
Contributor Author

@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

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

did a full pass in the github PR review UI and spotted some typos in comments

Comment thread pyo3-build-config/src/impl_.rs Outdated
Comment thread noxfile.py Outdated
Comment thread noxfile.py Outdated
@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I'm working on tests for maturin and spotted a bug in the abi3t-py315 feature. I added explicit tests for the feature but they won't fire until Python 3.16 gets added to the test matrix. I thought the check-feature-powerset tests would catch that but apparently not.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I added maturin tests over in PyO3/maturin#3113, which also serve as end-to-end tests of the packaging side of this PR.

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

Labels

CI-build-full CI-no-fail-fast If one job fails, allow the rest to keep testing free-threading proc-macro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the opaque PyObject ABI

3 participants