ENH: guard the Limited API target on free-threaded builds and fix bare Py_LIMITED_API tests (#32554)

This commit is contained in:
Pratham Hole authored and GitHub committed 2026-09-10 18:24:18 +05:30
1 parent 7f16df0fa2
commit b10c7a003a
4 files changed
+21 -10

No files matched your search

+17 -7
View File
@@ -14,13 +14,6 @@ project(
],
)
# Target version for the Limited C API, used by extension modules that
# have been ported. Controlled by python.allow_limited_api (default: false).
# The hex form is the same version, for targets that must define
# `Py_LIMITED_API` themselves; keep the two in sync.
py_limited_api = '3.13'
py_limited_api_hex = '0x030d0000'
fs = import('fs')
cc = meson.get_compiler('c')
@@ -44,6 +37,23 @@ if not cy.version().version_compare('>=3.1.0')
endif
py = import('python').find_installation(pure: false)
# Target version for the Limited C API, used by extension modules that
# have been ported. Controlled by python.allow_limited_api (default: false).
# The hex form is the same version, for targets that must define
# `Py_LIMITED_API` themselves; keep the two in sync.
#
# `Py_LIMITED_API` selects abi3, which is non-free-threaded only; the
# free-threaded ABI (abi3t) needs Python 3.15. Leave both empty on a
# free-threaded build, where a `limited_api:` kwarg would otherwise be acted
# on and produce a module that cannot be built.
if py.get_variable('Py_GIL_DISABLED', 0) == 0
py_limited_api = '3.13'
py_limited_api_hex = '0x030d0000'
else
py_limited_api = ''
py_limited_api_hex = ''
endif
py_dep = py.dependency()
if not cc.has_header('Python.h', dependencies: py_dep)
+1 -1
View File
@@ -183,7 +183,7 @@ typedef struct _tagPyUFuncObject {
* but this was never implemented. (This is also why the above
* selector is called the "legacy" selector.)
*/
#if !defined(Py_LIMITED_API) || Py_LIMITED_API >= 0x030C0000
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
vectorcallfunc vectorcall;
#else
void *vectorcall;
+2 -1
View File
@@ -870,7 +870,8 @@ py.extension_module('_multiarray_tests',
# library linked into one is still built against the unrestricted API and must
# be passed these args too. Drop this once
# https://github.com/mesonbuild/meson/issues/13824 is resolved.
py_limited_api_args = get_option('python.allow_limited_api') \
py_limited_api_args = (get_option('python.allow_limited_api')
and py_limited_api_hex != '') \
? ['-DPy_LIMITED_API=' + py_limited_api_hex] : []
_umath_tests_mtargets = mod_features.multi_targets(
+1 -1
View File
@@ -422,7 +422,7 @@ static struct PyModuleDef_Slot _pocketfft_umath_slots[] = {
#if PY_VERSION_HEX >= 0x030c00f0 // Python 3.12+
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
#endif
#if PY_VERSION_HEX >= 0x030d00f0 && (!defined(Py_LIMITED_API) || Py_LIMITED_API >= 0x030d0000) // Python 3.13+
#if PY_VERSION_HEX >= 0x030d00f0 && (!defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000) // Python 3.13+
// signal that this module supports running without an active GIL
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
#endif