Skip to content

Opaque PyObject ABI support#5807

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

Opaque PyObject ABI support#5807
ngoldbaum wants to merge 239 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.

Copy link
Copy Markdown
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Sorry for the slow review cycle, was busy this week at the Rust All Hands.

I think this is looking great and almost ready to merge. Comments are primarily cleanups, with the most involved suggestion being to gate append_to_inittab.

Comment thread guide/src/building-and-distribution.md Outdated
Comment thread guide/src/building-and-distribution.md Outdated
Comment thread pyo3-ffi/src/moduleobject.rs Outdated
Comment thread pyo3-ffi/src/object.rs Outdated
Comment thread pyo3-ffi/src/object.rs Outdated
Comment thread pyo3-ffi/src/object.rs Outdated
Comment thread pyo3-ffi/build.rs Outdated
Comment thread pyo3-ffi/build.rs Outdated
Comment thread pyo3-ffi/build.rs Outdated
Comment thread src/impl_/pymodule.rs
@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I was looking at trying to get the maturin integration tests passing on 3.15t today and noticed that cargo build --features=abi3-py39,abi3t-py315 dies inside the pyo3-ffi build script because the detected target ABI is abi3t-py39, which is definitely wrong.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I'm trying to stabilize the Maturin tests but that requires pushing here, sorry for the noise. The latest discovery was that zig cross-compilation was broken which indicates I probably need to add more unit tests for generating an InterpreterConfig for a free-threaded target.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

ngoldbaum commented May 27, 2026

It looks like Maturin's CI is now stable with all test crates updated to use this PR and CI running on both 3.15 interpreters.

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