Skip to content

Commit 9a3ee8c

Browse files
clin1234indygreg
authored andcommitted
build: update cffi versions and compatibility for 3.14 and nogil
We need cffi 2.0 for nogil support. cffi 2.0 only implements nogil support on 3.14+, so we need to disable cffi for nogil on 3.13.
1 parent 40282f8 commit 9a3ee8c

File tree

4 files changed

+138
-11
lines changed

4 files changed

+138
-11
lines changed

docs/news.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ Version History
2525
tests against a separate build that was theoretically identical. But the
2626
builds may have been subtly different, leading to preventable bugs in our
2727
wheels. (Enabling this test coverage did not uncover any failures.)
28+
* We now require cffi >= 2.0.0b on Python 3.14. <3.14 still requires 1.17.
29+
(#274)
30+
* The cffi backend is now automatically disabled for free-threaded builds
31+
on Python <3.14, as cffi didn't implement free-threaded support until
32+
the 2.0 release. (#274)
2833

2934
0.24.0 (released 2025-08-17)
3035
============================

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ dependencies = []
2525

2626
[project.optional-dependencies]
2727
cffi = [
28-
'cffi>=1.17 ; python_version >= "3.13" and platform_python_implementation != "PyPy"',
28+
"cffi~=1.17; platform_python_implementation != 'PyPy' and python_version < '3.14'",
29+
"cffi>=2.0.0b; platform_python_implementation != 'PyPy' and python_version >= '3.14'",
2930
]
3031

3132
[project.urls]
@@ -34,7 +35,8 @@ Documentation = "https://python-zstandard.readthedocs.io/en/latest/"
3435

3536
[build-system]
3637
requires = [
37-
"cffi>=1.17.0 ; platform_python_implementation != 'PyPy'",
38+
"cffi~=1.17; platform_python_implementation != 'PyPy' and python_version < '3.14'",
39+
"cffi>=2.0.0b; platform_python_implementation != 'PyPy' and python_version >= '3.14'",
3840
"packaging",
3941
"setuptools",
4042
]
@@ -43,7 +45,8 @@ build-backend = "setuptools.build_meta:__legacy__"
4345

4446
[dependency-groups]
4547
dev = [
46-
"cffi>=1.17.0 ; platform_python_implementation != 'PyPy'",
48+
"cffi~=1.17; platform_python_implementation != 'PyPy' and python_version < '3.14'",
49+
"cffi>=2.0.0b; platform_python_implementation != 'PyPy' and python_version >= '3.14'",
4750
"hypothesis==6.111.0",
4851
"mypy>=1.17.1",
4952
"pytest>=8.4.1",

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import platform
1212
import sys
13+
import sysconfig
1314

1415
from setuptools import setup
1516

@@ -30,7 +31,8 @@
3031
# garbage collection pitfalls.
3132
# Require 1.17 everywhere so we don't have to think about supporting older
3233
# versions.
33-
MINIMUM_CFFI_VERSION = "1.17"
34+
# Require 2.0 for Python 3.14+ to add improved free-threading support
35+
MINIMUM_CFFI_VERSION = "2.0" if sys.version_info[0:2] >= (3, 14) else "1.17"
3436

3537
ext_suffix = os.environ.get("SETUPTOOLS_EXT_SUFFIX")
3638
if ext_suffix:
@@ -89,6 +91,16 @@
8991
if platform.python_implementation() == "PyPy":
9092
C_BACKEND = False
9193

94+
# cffi 2.0 only introduced no-GIL support for 3.14+.
95+
if sys.version_info[0:2] < (3, 14) and sysconfig.get_config_var(
96+
"Py_GIL_DISABLED"
97+
):
98+
print(
99+
"cffi backend requires 3.14+ for nogil Python; disabling cffi",
100+
file=sys.stderr,
101+
)
102+
CFFI_BACKEND = False
103+
92104
if "--legacy" in sys.argv:
93105
SUPPORT_LEGACY = True
94106
sys.argv.remove("--legacy")

0 commit comments

Comments
 (0)