diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fd5b36e9..374e8ba9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -504,9 +504,9 @@ jobs: with: matrix_yaml: | include: - - { runner: ubuntu-24.04, python-version: 3.14t } - - { runner: macos-26, python-version: 3.14t } - - { runner: windows-2025, python-version: 3.14t } + - { runner: ubuntu-24.04, python-version: 3.15t-dev } + - { runner: macos-26, python-version: 3.15t-dev } + - { runner: windows-2025, python-version: 3.15t-dev } pytest-run-parallel: needs: make_run_parallel_matrix @@ -536,7 +536,7 @@ jobs: clang_TSAN: runs-on: ubuntu-24.04 - container: ghcr.io/nascheme/numpy-tsan:3.14t + container: ghcr.io/nascheme/numpy-tsan:3.15t-dev steps: - uses: actions/checkout@v4 diff --git a/src/cffi/_cffi_include.h b/src/cffi/_cffi_include.h index c7186307..c8c6d343 100644 --- a/src/cffi/_cffi_include.h +++ b/src/cffi/_cffi_include.h @@ -28,8 +28,13 @@ #if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API) # ifdef _MSC_VER # if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API) -# define Py_LIMITED_API +# if !defined(Py_GIL_DISABLED) +# define Py_LIMITED_API +# else +# define Py_LIMITED_API 0x030f0000 +# endif # endif + # include /* sanity-check: Py_LIMITED_API will cause crashes if any of these are also defined. Normally, the Python file PC/pyconfig.h does not @@ -49,7 +54,11 @@ # else # include # if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API) -# define Py_LIMITED_API +# if !defined(Py_GIL_DISABLED) +# define Py_LIMITED_API +# else +# define Py_LIMITED_API 0x030f0000 +# endif # endif # endif #endif diff --git a/src/cffi/recompiler.py b/src/cffi/recompiler.py index 83ee5c7d..6f2debe5 100644 --- a/src/cffi/recompiler.py +++ b/src/cffi/recompiler.py @@ -9,7 +9,7 @@ USE_LIMITED_API = ((sys.platform != 'win32' or sys.version_info < (3, 0) or sys.version_info >= (3, 5)) and - not sysconfig.get_config_var("Py_GIL_DISABLED")) # free-threaded doesn't yet support limited API + (not sysconfig.get_config_var("Py_GIL_DISABLED") or sys.version_info >= (3, 15))) # free-threaded doesn't yet support limited API class GlobalExpr: def __init__(self, name, address, type_op, size=0, check_value=0): diff --git a/src/cffi/setuptools_ext.py b/src/cffi/setuptools_ext.py index 5cdd246f..319ab0f2 100644 --- a/src/cffi/setuptools_ext.py +++ b/src/cffi/setuptools_ext.py @@ -105,10 +105,12 @@ def _set_py_limited_api(Extension, kwds): kwds['py_limited_api'] = True if sysconfig.get_config_var("Py_GIL_DISABLED"): - if kwds.get('py_limited_api'): - log.info("Ignoring py_limited_api=True for free-threaded build.") - - kwds['py_limited_api'] = False + if sys.version_info < (3, 15): + if kwds.get('py_limited_api'): + log.info("Ignoring py_limited_api=True for free-threaded build.") + kwds['py_limited_api'] = False + else: + kwds["define_macros"].append(("Py_TARGET_ABI3T", "0x030f0000")) if kwds.get('py_limited_api') is False: # avoid setting Py_LIMITED_API if py_limited_api=False