Add support for free-threaded builds (#70)

* Build free-threaded wheels, disable limited API there

Co-authored-by: Min RK <151929+minrk@users.noreply.github.com>

* Try installing libffi-dev on Linux

It's faling due to lack of includes. Presumably because the lack of cffi
wheels.

* Revert "Try installing libffi-dev on Linux"

Does not work.

* Merge

* Actually build FT

* support the free-threaded build of Python 3.14 (#93)

* support the free-threaded build of Python 3.14

* attempt to get 3.14t CI to run

* Add trove classifier

* Add changelog

* Add 3.14 trove classifier, too

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>

---------

Co-authored-by: Min RK <151929+minrk@users.noreply.github.com>
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
This commit is contained in:
Hynek Schlawack 2025-07-30 08:53:31 +02:00 committed by GitHub
parent 3ed9734847
commit 1aad4747f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 27 additions and 6 deletions

View File

@ -29,6 +29,7 @@ jobs:
- "3.12"
- "3.13"
- "3.14"
- "3.14t"
- "pypy-3.9"
- "pypy-3.10"
@ -56,7 +57,7 @@ jobs:
echo TOX_PYTHON=$V >>$GITHUB_ENV
- run: python -Im tox run -f $TOX_PYTHON
- run: python -Im tox run -e $TOX_PYTHON
system-package:
runs-on: ubuntu-latest

View File

@ -31,7 +31,7 @@ jobs:
persist-credentials: false
# See pyproject.toml for config.
- uses: pypa/cibuildwheel@v3.0
- uses: pypa/cibuildwheel@v3.1
- uses: actions/upload-artifact@v4
with:

View File

@ -25,6 +25,9 @@ Vendoring Argon2 @ [**`f57e61e`**](https://github.com/P-H-C/phc-winner-argon2/co
- Official Python 3.12, 3.13, and 3.14 support.
No code or packaging changes were necessary.
- Support for free-threading (aka nogil) on Python 3.14.
[#93](https://github.com/hynek/argon2-cffi-bindings/pull/93)
### Removed

View File

@ -2,7 +2,8 @@
requires = [
"setuptools>=77",
"setuptools_scm[toml]>=6.2",
"cffi>=1.0.1",
"cffi>=1.0.1; python_version < '3.14'",
"cffi>=2.0.0b1; python_version >= '3.14'",
]
build-backend = "setuptools.build_meta"
@ -30,13 +31,18 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Free Threading",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Security :: Cryptography",
"Topic :: Security",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = ["cffi>=1.0.1"]
dependencies = [
"cffi>=1.0.1; python_version < '3.14'",
"cffi>=2.0.0b1; python_version >= '3.14'",
]
[project.optional-dependencies]
tests = ["pytest"]
@ -61,6 +67,7 @@ local_scheme = "no-local-version"
[tool.cibuildwheel]
build = [
"cp39-*" , # We have portable abi3 wheels.
"cp314t-*", # Free-threading / nogil.
"pp310-*", # PyPy 3.9 is EOL and doesn't build on Windows anymore.
]
enable = ["pypy"]

View File

@ -2,6 +2,7 @@
import platform
import sys
import sysconfig
from setuptools import setup
@ -17,7 +18,11 @@ if platform.python_implementation() == "CPython":
class BDistWheel(bdist_wheel):
def finalize_options(self):
self.py_limited_api = f"cp3{sys.version_info[1]}"
# Free-threaded CPython doesn't support limited API.
if sysconfig.get_config_var("Py_GIL_DISABLED"):
self.py_limited_api = False
else:
self.py_limited_api = f"cp3{sys.version_info[1]}"
super().finalize_options()

View File

@ -2,6 +2,7 @@
import os
import platform
import sysconfig
from pathlib import Path
@ -11,6 +12,8 @@ from cffi import FFI
use_system_argon2 = os.environ.get("ARGON2_CFFI_USE_SYSTEM", "0") == "1"
use_sse2 = os.environ.get("ARGON2_CFFI_USE_SSE2", None)
windows = platform.system() == "Windows"
# Free-threaded CPython doesn't support limited API.
limited_api = not sysconfig.get_config_var("Py_GIL_DISABLED")
# Try to detect cross-compilation.
@ -48,6 +51,7 @@ if use_system_argon2:
"_ffi",
"#include <argon2.h>",
libraries=["argon2"],
py_limited_api=limited_api,
)
else:
lib_base = Path("extras") / "libargon2" / "src"
@ -56,6 +60,7 @@ else:
"#include <argon2.h>",
extra_compile_args=["-msse2"] if (optimized and not windows) else None,
include_dirs=[str(Path("extras", "libargon2", "include"))],
py_limited_api=limited_api,
sources=[
str(lib_base / path)
for path in [

View File

@ -10,7 +10,7 @@ min_version = 4
env_list =
pre-commit,
cog-{check,render},
py3{9,10,11,12,13,14},
py3{9,10,11,12,13,14,14t},
pypy3{9,10},
system-argon2