Skip to content

ENH: add support for PEP 803 abi3t with Python 3.15.0b2+#856

Open
mgorny wants to merge 2 commits into
mesonbuild:mainfrom
mgorny:abi3t
Open

ENH: add support for PEP 803 abi3t with Python 3.15.0b2+#856
mgorny wants to merge 2 commits into
mesonbuild:mainfrom
mgorny:abi3t

Conversation

@mgorny

@mgorny mgorny commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Add tag/extension support and initial tests for abi3t as specified in PEP 803 and implemented in Python 3.15.0b2. This is currently limited to building abi3t extensions from freethreading builds of Python, since Meson does not support forcing abi3t builds explicitly right now. See mesonbuild/meson#15637 for the relevant discussion.

The additional test case utilizes the new API introduced in PEP 793 and PEP 820, and therefore requires Python 3.15.0b2. The relevant test tests wheel correctness both with GIL-enabled and free-threading builds of Python 3.15.0b2.

The behavior for older versions of Python remains unchanged.

@mgorny

mgorny commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

I didn't touch the test matrix, since testing on 3.15 is already being addressed by #853.

Comment thread mesonpy/__init__.py Outdated
Comment thread tests/packages/limited-api-ft/meson.build
Comment thread mesonpy/__init__.py Outdated
Comment thread mesonpy/__init__.py Outdated
Comment thread tests/test_editable.py Outdated


@pytest.mark.skipif(NOGIL_BUILD and CYTHON_VERSION < (3, 1, 0),
@pytest.mark.skipif(mesonpy._is_free_threaded() and CYTHON_VERSION < (3, 1, 0),

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.

I think the NOGIL_BUILD was more self explanatory. Reading the function call mesonpy._is_free_threaded() I would imagine that what has the property of being free threaded is mesonpy, which does not make much sense.

I would keep the old constant.

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.

Do you think it would be better to put it as a constant in mesonpy? I was torn between using a function and a constant, given this is fixed value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Constant seems fine to me. Slight preference for FREE_THREADED_BUILD over NOGIL_BUILD (the latter name will fade over time I think), but I don't care that much either way.

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.

@rgommers IIRC it was you that introduced the NOGIL_BUILD constant 🙂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Guilty:) I guess that was early days, before the Steering Council pronounced that that was a negative name and they wanted everyone to use free-threading/free-threaded everywhere.

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.

For now, I've focused on the changes relevant to the PR. Do you want me to change the constant name, and possibly move it to mesonpy/__init__.py here, or separately?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For now, I've focused on the changes relevant to the PR.

That sounds fine to me - small diffs are nice

Comment thread mesonpy/__init__.py Outdated
Comment thread mesonpy/__init__.py Outdated
@rgommers rgommers added the enhancement New feature or request label Jun 24, 2026
@rgommers rgommers added this to the v0.21.0 milestone Jun 24, 2026
@rgommers

Copy link
Copy Markdown
Contributor

Downstream testing, and releasing after rc1 in early August, is currently blocked on this, so I added a v0.21.0 tag - we should do that next month I think.

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A couple of small issues in the test extension. The rest looks right; I refreshed my memory on Py_TARGET_ABI3T and that should be added automatically in Python.h for a free-threaded interpreter if Py_LIMITED_API is defined - so all good there.

Comment thread tests/packages/limited-api-ft/module.c Outdated
Comment thread tests/packages/limited-api-ft/module.c Outdated
Comment thread tests/test_tags.py
@rgommers

Copy link
Copy Markdown
Contributor

This is looking pretty good now. Are you expecting it to be squash-merged, or do you want to rewrite history? (we usually do the latter, and rebase-merge)

Add tag/extension support and initial tests for `abi3t` as specified
in PEP 803 and implemented in Python 3.15.0b2.  This is currently
limited to building `abi3t` extensions from freethreading builds of
Python, since Meson does not support forcing `abi3t` builds explicitly
right now.  See mesonbuild/meson#15637
for the relevant discussion.

The additional test case utilizes the new API introduced in PEP 793
and PEP 820, and therefore requires Python 3.15.0b2.  The relevant test
tests wheel correctness both with GIL-enabled and free-threading builds
of Python 3.15.0b2.

The behavior for older versions of Python remains unchanged.

Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
@mgorny

mgorny commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Rewrote it now. I've kept (and reworded) the commit changing limited-api test separate.

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM now, thanks @mgorny.

@dnicolodi WDYT about releasing this quickly as 0.21.0? Getting this supported would be nice, makes it more likely package authors will experiment with it before the ABI gets frozen in 5-6 weeks from now. I had a look through the rest of the PR queue, and nothing else is critical, although PR 838 is close and we could aim to get that in as well.

@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2023-2026 The meson-python developers

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.

I would prefer if this test case would get a more descriptive name. I'm sure that before tomorrow I'm going to forget what ft stands for. If spelling it out as limited-api-free-threaded is too long, maybe limited-api-pep803 or limited-api-abi3t?

@dnicolodi

Copy link
Copy Markdown
Member

LGTM too, with the minor exception of the test package name: I am sure that I will promptly forget what ft stands for, thus a longer more descriptive name would help there.

I had a look through the rest of the PR queue, and nothing else is critical, although PR 838 is close and we could aim to get that in as well.

I can try to get that in shape this evening. I would still like to get the RPATH handling in order sooner rather than later, but I didn't find the time to finish that work. I guess we can go another release without it.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants