Refactor to store CPython ABI metadata in a struct combining two enums#3110
Merged
Refactor to store CPython ABI metadata in a struct combining two enums#3110
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors how PyO3/CPython stable-ABI build metadata is represented by replacing the old Abi3Version enum with a StableAbi struct combining StableAbiKind + StableAbiVersion, to prepare for future abi3t support (PEP 803) while aiming to keep current behavior the same.
Changes:
- Introduces
StableAbi,StableAbiKind, andStableAbiVersion, and threads them through bridge detection and public exports. - Updates build orchestration, wheel tag generation, and binding generation to use
stable_abimetadata. - Updates tests and project scaffolding to the new
stable_abifield name.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/python_interpreter/resolver.rs | Switches resolver logic from abi3 version enum to stable_abi.version. |
| src/python_interpreter/mod.rs | Adjusts stable-API capability detection for interpreters. |
| src/python_interpreter/discovery.rs | Updates test bridge models to use stable_abi field name. |
| src/new_project.rs | Updates generated project bridge config to initialize stable_abi: None. |
| src/lib.rs | Re-exports new stable-ABI types from bridge. |
| src/ci/github/tests.rs | Updates CI generation tests to pass StableAbi instead of Abi3Version. |
| src/build_orchestrator.rs | Refactors stable-ABI wheel building/tagging paths around StableAbiKind + StableAbiVersion. |
| src/build_options.rs | Updates build options tests to use StableAbi::from_abi3_version. |
| src/bridge/mod.rs | Defines new stable-ABI types and replaces PyO3.abi3 with PyO3.stable_abi. |
| src/bridge/detection.rs | Generalizes feature parsing to stable-ABI kind/version, preparing for additional kinds. |
| src/binding_generator/pyo3_binding.rs | Refactors binding generation to accept an optional StableAbiKind and centralizes ext suffix logic. |
messense
reviewed
Mar 30, 2026
messense
reviewed
Mar 31, 2026
messense
reviewed
Mar 31, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: messense <messense@icloud.com>
messense
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Towards #3064.
This is purely refactoring, there should be no functional changes as a result of this.
Currently the build metadata special-cases ABI3 builds or more generally assumes stable ABI builds and ABI3 builds are the same thing. With PEP 803 and the new abi3t ABI in Python 3.15, that is no longer the case.
This replaces the old
ABI3Versionenum with a new struct combining two enums:StableAbiVersionis just the oldAbi3Versionenum renamed since the concept of a minimum supported version is shared by abi3t.I have a branch that adds an
Abi3tvariant forStableAbiKind. My goal with this PR is to make reviewing the subsequent PR adding abi3t support easier.Also see PyO3/pyo3#5924 where I made a similar change in PyO3. Here in Maturin I needed different types but in principle I could make the two implementations use shared code. I'm not sure if that's actually useful for anything in practice.