Skip to content

Add initial support for abi3.abi3t tag from PEP 803#5193

Open
ngoldbaum wants to merge 14 commits intopypa:mainfrom
ngoldbaum:abi3.abi3t
Open

Add initial support for abi3.abi3t tag from PEP 803#5193
ngoldbaum wants to merge 14 commits intopypa:mainfrom
ngoldbaum:abi3.abi3t

Conversation

@ngoldbaum
Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum commented Mar 3, 2026

Summary of changes

Fixes #5205

PEP 803 proposes a free-threaded stable ABI. I'm working on ecosystem support for a free-threaded stable ABI and end-to-end tests for PEP 803. PEP 803 was accepted in March and there will be support for it in Python 3.15.

This PR is set up to require a free-threaded build to produce abi3.abi3t wheels. It does this by making builds where py_limited_api=True is set on the free-threaded build on 3.15 or newer produce abi3t extensions and abi3.abi3t wheels.

In principle it's possible to do this on the GIL-enabled build as well but it'll require at least a new Extension keyword argument py_target_abi3t=True maybe?

As far as I can tell, py_limited_api is undocumented, so this doesn't add new docs, although I'd be happy to explore that if you'd like to see docs for this.

Pull Request Checklist

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

ngoldbaum commented Mar 6, 2026

I'll do another pass next week to get the tests passing here. In the meantime, I'd appreciate comments.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

ngoldbaum commented Mar 16, 2026

In order to make the diff coverage happy, I'll probably need to:

  • Add CI for Python 3.15
  • Add free-threaded CI coverage for 3.14 and 3.15
  • Add a new test extension that sets py_limited_api = True for an Extension object and then also sets py_limited_api=cp315 in setup.cfg.

I'm going to punt on that for now but I hope to come back to that. I also think free-threaded CI coverage is probably needed independent of the PEP 803 work.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

Actually, on second thought, I think I might be able to use unittest.mock to fake a free-threaded build.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

Fun! It looks like a more-itertools release broke the type checking test.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I looked at Python 3.15 testing a bit today and ran into ronaldoussoren/pyobjc#671. Even if that isn't a problem on CI, the full pyobjc dependency tree takes quite a while to build, so any 3.15 testing will be Linux-only for now probably.

It probably does make sense to add an abi3t test extension that requires Python 3.15 or newer, but I'm going to punt on that for now.

Besides that issue, all code in this PR is tested.

Copy link
Copy Markdown

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @ngoldbaum. Overall this PR looks solid, I only found one minor issue in one of the added tests in test_build_ext.py.

Comment thread setuptools/tests/test_build_ext.py Outdated
Comment thread setuptools/command/bdist_wheel.py Outdated
Extension(
name="extension",
sources=["extension.c"],
py_limited_api=True
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This change looks correct and is a bug fix for the existing test, which didn't quite make sense before - I think given the test_limited_abi test name, it was intended to test the Limited API indeed.

@ngoldbaum ngoldbaum marked this pull request as ready for review April 22, 2026 19:27
@ngoldbaum
Copy link
Copy Markdown
Contributor Author

I marked this ready for review and updated the PR description. @jaraco @abravalheri I'd love your opinions on this.

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.

[FR] Support building extensions and wheels with the abi3t ABI (PEP 803)

3 participants