-
Notifications
You must be signed in to change notification settings - Fork 88
ENH: add support for PEP 803 abi3t with Python 3.15.0b2+
#856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
22b8118
0d43c65
a23fe90
bf0fb07
c20b470
27e23c8
1a16140
66ebdd1
f18d1ca
e56474b
ede9744
a0aa5e1
1657f0b
f816e00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # SPDX-FileCopyrightText: 2023-2026 The meson-python developers | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| project('limited-api-ft', 'c', version: '1.0.0', meson_version: '>= 1.3') | ||
|
|
||
| py = import('python').find_installation(pure: false) | ||
|
|
||
| py.extension_module( | ||
| 'module', | ||
| 'module.c', | ||
| limited_api: '3.15', | ||
| install: true, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // SPDX-FileCopyrightText: 2023-2026 The meson-python developers | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include <Python.h> | ||
|
|
||
| static PyObject* add(PyObject *self, PyObject *args) { | ||
| int a, b; | ||
|
|
||
| if (!PyArg_ParseTuple(args, "ii", &a, &b)) | ||
| return NULL; | ||
|
|
||
| return PyLong_FromLong(a + b); | ||
| } | ||
|
|
||
| static PyMethodDef methods[] = { | ||
| {"add", add, METH_VARARGS, NULL}, | ||
| {NULL, NULL, 0, NULL}, | ||
| }; | ||
|
|
||
| PyABIInfo_VAR(abi_info); | ||
|
|
||
| static PySlot module_slots[] = { | ||
| PySlot_STATIC_DATA(Py_mod_name, "module"), | ||
| PySlot_STATIC_DATA(Py_mod_methods, methods), | ||
| PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED), | ||
| PySlot_DATA(Py_mod_abi, &abi_info), | ||
| PySlot_END, | ||
| }; | ||
|
|
||
| PyMODEXPORT_FUNC PyModExport_module(void) { | ||
| return module_slots; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # SPDX-FileCopyrightText: 2023-2026 The meson-python developers | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| [build-system] | ||
| build-backend = 'mesonpy' | ||
| requires = ['meson-python'] | ||
|
|
||
| [tool.meson-python] | ||
| limited-api = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import mesonpy._tags | ||
|
|
||
| from .conftest import adjust_packaging_platform_tag | ||
| from .test_wheel import NOGIL_BUILD | ||
|
|
||
|
|
||
| # Test against the wheel tag generated by packaging module. | ||
|
|
@@ -29,6 +30,9 @@ | |
|
|
||
|
|
||
| def get_abi3_suffix(): | ||
| # EXTENSION_SUFFIXES are ordered in preference order, and more specific ABI is preferred. | ||
| # On free-threaded 3.15+, this will match ".abi3t" as the only supported stable ABI. | ||
| # On GIL-enabled 3.15+, it will match plain ".abi3" first, since that ABI is more specific. | ||
| for suffix in importlib.machinery.EXTENSION_SUFFIXES: | ||
| if '.abi3' in suffix: # Unix | ||
| return suffix | ||
|
|
@@ -130,7 +134,12 @@ def test_tag_stable_abi(): | |
| 'platlib': [f'extension{ABI3SUFFIX}'], | ||
| }, limited_api=True) | ||
| # PyPy does not support the stable ABI. | ||
| abi = 'abi3' if '__pypy__' not in sys.builtin_module_names else ABI | ||
| if '__pypy__' in sys.builtin_module_names: | ||
| abi = ABI | ||
| elif NOGIL_BUILD and sys.version_info >= (3, 15): | ||
| abi = 'abi3.abi3t' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that, if this works, it does by chance. The fake data passed to the wheel builder uses
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment would be great. My understanding is that it is guaranteed - and Meson relies on it as well, which came up in the PEP 803 discussions. (that said, future-proofing might be wise).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is guaranteed, CPython is driving module loading on it. For GIL-enabled, it's: >>> importlib.machinery.EXTENSION_SUFFIXES
['.cpython-315-x86_64-linux-gnu.so', '.abi3.so', '.abi3t.so', '.so']It's ordered from most specific (i.e. presumably most performant) to least specific, to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this mean that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nope, This is actually explicitly specified in PEP 803: https://peps.python.org/pep-0803/#the-abi3t-wheel-and-filename-tags There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And yes, |
||
| else: | ||
| abi = 'abi3' | ||
| assert str(builder.tag) == f'{INTERPRETER}-{abi}-{PLATFORM}' | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.