Skip to content

Commit 65ec6ca

Browse files
committed
Split minimum cffi version depending on Python version
cffi 1.17 for Python up to 3.13, 2.0 for 3.14+
1 parent ee643bc commit 65ec6ca

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

pyproject.toml

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

2626
[project.optional-dependencies]
2727
cffi = [
28-
'cffi>=2.0.0b1 ; 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>=2.0.0b1 ; 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
]

setup.py

Lines changed: 7 additions & 2 deletions
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,8 +31,8 @@
3031
# garbage collection pitfalls.
3132
# Require 1.17 everywhere so we don't have to think about supporting older
3233
# versions.
33-
# Require 2.0 for improved free-threading support
34-
MINIMUM_CFFI_VERSION = "2.0"
34+
# Require 2.0 when building with 3.14+ for improved free-threading support
35+
MINIMUM_CFFI_VERSION = "2.0" if sys.version_info[0:2] >= (3, 14) else "1.17"
3536

3637
ext_suffix = os.environ.get("SETUPTOOLS_EXT_SUFFIX")
3738
if ext_suffix:
@@ -90,6 +91,10 @@
9091
if platform.python_implementation() == "PyPy":
9192
C_BACKEND = False
9293

94+
# cffi only supports no-GIL with Python 3.14+
95+
if platform.python_implementation() == "CPython" and sys.version_info[0:2] == (3, 13) and sysconfig.get_config_var("Py_GIL_DISABLED"):
96+
CFFI_BACKEND = False
97+
9398
if "--legacy" in sys.argv:
9499
SUPPORT_LEGACY = True
95100
sys.argv.remove("--legacy")

0 commit comments

Comments
 (0)