Skip to content

Support pyo3 abi3t features on Python3.15 and PyO3 0.29#3113

Merged
messense merged 37 commits into
PyO3:mainfrom
ngoldbaum:abi3t
Jun 11, 2026
Merged

Support pyo3 abi3t features on Python3.15 and PyO3 0.29#3113
messense merged 37 commits into
PyO3:mainfrom
ngoldbaum:abi3t

Conversation

@ngoldbaum

@ngoldbaum ngoldbaum commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Adds support for the new abi3t ABI in Python 3.15. See https://pyo3.rs/main/building-and-distribution.html?highlight=abi3t#py_limited_apiabi3abi3t for more info from the pyo3 side of things.

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

@messense do you have any opinions about how tests for abi3t support should look? My first instinct would be to follow and generalize the existing tests for abi3. Does that sound like a good plan, or do you have large test refactorings in mind separate from this?

@messense

messense commented Apr 9, 2026

Copy link
Copy Markdown
Member

Sorry missed the reply in the issue, follow and generalize the existing tests for abi3 sounds good to me.

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

Sorry missed the reply in the issue, follow and generalize the existing tests for abi3 sounds good to me.

Sorry for the delay over here. I just added some new tests. Since abi3t support requires Python 3.15 or newer, I needed to also add some utilities to introspect the Python used by the test runner.

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

I don't think there are any tests for Python 3.15 yet. @messense what do you think about replacing 3.14 and 3.14t in test.yml with 3.15-dev and 3.15t-dev in this PR?

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

I should also note that the new test crates depend on my PR branch for PyO3/pyo3#5807 and I'll need to update them after that PyO3 PR is merged and PyO3 does a release. Not quite sure how to sequence landing everything.

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

@messense what do you think about replacing 3.14 and 3.14t in test.yml with 3.15-dev and 3.15t-dev in this PR?

Never mind, I tried and it will require some more work to get that stable. See the CI run associated with ee98a08.

@ngoldbaum ngoldbaum mentioned this pull request May 22, 2026
Comment thread src/bridge/mod.rs Outdated
/// minimum version. Version‑specific fallback builds (e.g. Python 3.10 when
/// abi3 targets ≥ 3.11) return `false` so that `Py_LIMITED_API` is not
/// defined and interpreter‑specific linker names are used.
pub fn is_abi3_for_interpreter(&self, interpreter: &PythonInterpreter) -> bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where does this function end up being needed over is_stable_abi_for_interpreter?

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.

Good call - I think I needed it in an earlier version of this PR but I can delete it now and simplify things a lot.

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.

Oh no, that's wrong. It's load-bearing in the implementation of configure_pyo3_env, which ends up generating a pyo3 configuration file using the abi3 key. I probably need to detect the pyo3 version and generate an appropriate config file with a target_abi key if I find a new-enough pyo3.

@ngoldbaum ngoldbaum May 25, 2026

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.

I added a new use_target_abi argument to configure_pyo3_env and set up maturin to generate a configuration file with an abi3 or target_abi argument based on the detected PyO3 version. This let me delete is_abi3_for_interpreter.

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

OK, I think CI is stabilized. Not sure what's up with the remaining Mac pypy3.11 failures, but I think they're caused by a change in PyO3 unrelated to abi3t support (PyO3/pyo3#6041).

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

Also I should say that I had to drop 3.13t from the interpreters considered for interpreter discovery, since PyO3 dropped 3.13t support.

@ngoldbaum

Copy link
Copy Markdown
Contributor Author

PyO3/pyo3#6078 fixes the PyPy linker issue causing the remaining test failures.

@ngoldbaum

ngoldbaum commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for all the noise the past few days and the substantial growth of this PR. I realized that I wasn't actually running the integration tests locally on Python 3.15, but once I realized that the maturin CI uses cargo nextest and figured out I need to edit the test crates to point at my PyO3 PR, I discovered a number of additional issues that needed fixing in PyO3 and in Maturin.

That said, I think the implementation is ready to review now and is only waiting for PyO3 to do a 0.29 release include abi3t support.

There probably need to be docs as well, I will look at that next week I think.

@messense

messense commented Jun 1, 2026

Copy link
Copy Markdown
Member

I'm holding off review this PR until it's out of draft state, ping me if I missed any notifications, thanks!

messense added a commit that referenced this pull request Jun 1, 2026
…eters (#3206)

This is partially extracted from #3113.

Currently, free-threaded interpreters are not always considered for
`--find-interpreters`. It is included on Unix but not on Windows. This
means that users need to explicitly do another build to produce 3.14t
wheels. This also contributes to
PyO3/maturin-action#368 and I'm planning to do
a followup over there to fix that once this is merged.

With this PR, `--find-interpreters` always picks up 3.14t and newer. I
intentionally excluded 3.13t because PyO3 0.29 will refuse to build
wheels for 3.13t. This also follows manylinux, which recently dropped
3.13t from the images.

---------

Co-authored-by: messense <messense@icloud.com>
@ngoldbaum

Copy link
Copy Markdown
Contributor Author

I think I understand the cause of the random Windows failures, see pypa/pip#9034. In short, pip's cache isn't safe to concurrently write to on Windows like maturin's CI does. I pushed a commit disabling pip caching, which hopefully doesn't negatively impact CI times too much.

@ngoldbaum ngoldbaum marked this pull request as ready for review June 3, 2026 14:31
@ngoldbaum

Copy link
Copy Markdown
Contributor Author

This is still not ready to merge because PyO3 hasn't yet done a release and I'll need to update the test crates one final time. That said, I just added some documentation and marked this ready for review because it's otherwise totally ready.

IMO it'd be a good idea to coordinate merging this and quickly cutting a release with the PyO3 0.29 release.

messense pushed a commit that referenced this pull request Jun 3, 2026
Per [the CFFI
docs](https://cffi.readthedocs.io/en/latest/installation.html#installation-and-status),
PyPy vendors CFFI and installing it and requiring it is unnecessary.
This is particularly annoying because cffi doesn't ship PyPy wheels, so
it triggers an unnecessary C build at install time.

Also see, for example, the way [cryptography handles
this](https://github.com/pyca/cryptography/blob/ba936e527bc4e3948c338a7bde54c3bd81957c61/pyproject.toml#L8).

I noticed this was an issue in the CI for #3113, which saw failures
related to the unnecessary CFFI builds failing.

@messense messense left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks, let's wait for pyo3 0.29 release then update and merge this.

@ngoldbaum ngoldbaum changed the title Initial support for abi3t, depends on unreleased PyO3 features. Support pyo3 abi3t features on Python3.15 and PyO3 0.29 Jun 11, 2026
@ngoldbaum

Copy link
Copy Markdown
Contributor Author

Updated to use PyO3 0.29 in the test crates. Everything passes locally but let's see what CI says.

@messense messense merged commit e18aba6 into PyO3:main Jun 11, 2026
44 of 45 checks 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.

3 participants