Skip to content

Commit 4ba12d8

Browse files
authored
feat: test on free‑threaded Python (#676)
* feat: test on free‑threaded Python * add 3.14t to noxfile * try splitting numba as a standalone dep-group * fix doctests and notebooks * added free threading stable classifier
1 parent fd1a553 commit 4ba12d8

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- "3.12"
4545
- "3.13"
4646
- "3.14"
47+
- "3.14t"
4748
name: Python ${{ matrix.python-version }} - Lite
4849
steps:
4950
- uses: actions/checkout@v6
@@ -71,6 +72,7 @@ jobs:
7172
- "3.12"
7273
- "3.13"
7374
- "3.14"
75+
- "3.14t"
7476
name: Python ${{ matrix.python-version }} - Full
7577
steps:
7678
- uses: actions/checkout@v6

noxfile.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
from __future__ import annotations
88

9+
import os
10+
import sys
11+
import sysconfig
912
from pathlib import Path
1013

1114
import nox
@@ -16,6 +19,7 @@
1619
DIR = Path(__file__).parent.resolve()
1720
PYPROJECT = nox.project.load_toml(DIR / "pyproject.toml")
1821
ALL_PYTHON = nox.project.python_versions(PYPROJECT)
22+
ALL_PYTHON += ["3.14t"] # add free-threaded Python variant
1923

2024

2125
@nox.session(reuse_venv=True)
@@ -44,7 +48,13 @@ def lite(session: nox.Session) -> None:
4448
@nox.session(reuse_venv=True, python=ALL_PYTHON)
4549
def tests(session: nox.Session) -> None:
4650
"""Run the unit and regular tests."""
47-
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all")
51+
if sys.version_info[:2] >= (3, 14) and bool(
52+
sysconfig.get_config_var("Py_GIL_DISABLED")
53+
):
54+
os.environ["PYTHON_GIL"] = "0"
55+
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all-no-gil")
56+
else:
57+
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all-gil")
4858
session.install("-e.", *test_deps)
4959
session.run(
5060
"pytest",
@@ -64,15 +74,17 @@ def coverage(session: nox.Session) -> None:
6474
@nox.session(reuse_venv=True, python=ALL_PYTHON)
6575
def doctests(session: nox.Session) -> None:
6676
"""Run the doctests."""
67-
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all")
77+
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all-gil")
6878
session.install("-e.", *test_deps)
6979
session.run("pytest", "--doctest-plus", "src/vector/", *session.posargs)
7080

7181

7282
@nox.session(reuse_venv=True, default=False)
7383
def notebooks(session: nox.Session) -> None:
7484
"""Run the notebook tests"""
75-
test_deps = nox.project.dependency_groups(PYPROJECT, "test", "test-optional")
85+
test_deps = nox.project.dependency_groups(
86+
PYPROJECT, "test", "test-optional", "test-numba"
87+
)
7688
session.install("-e.", *test_deps)
7789
session.install("jupyter")
7890
session.run("pytest", "tests/test_notebooks.py", *session.posargs)

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ classifiers = [
3333
"Programming Language :: Python :: 3.12",
3434
"Programming Language :: Python :: 3.13",
3535
"Programming Language :: Python :: 3.14",
36+
"Programming Language :: Python :: Free Threading :: 3 - Stable",
3637
"Topic :: Scientific/Engineering",
3738
"Topic :: Scientific/Engineering :: Information Analysis",
3839
"Topic :: Scientific/Engineering :: Mathematics",
@@ -72,9 +73,11 @@ test = [
7273
]
7374
test-optional = [
7475
"awkward>=2",
75-
"numba>=0.57; python_version<'3.15'",
7676
"sympy",
7777
]
78+
test-numba = [
79+
"numba>=0.57; python_version<'3.15'",
80+
]
7881
test-extras = [
7982
"jax",
8083
"dask_awkward",
@@ -94,14 +97,19 @@ docs = [
9497
"hepunits",
9598
"matplotlib",
9699
]
97-
test-all = [
100+
test-all-no-gil = [
98101
{ include-group = "test"},
99102
{ include-group = "test-optional"},
100103
{ include-group = "test-extras"},
101104
]
105+
test-all-gil = [
106+
{ include-group = "test-all-no-gil"},
107+
{ include-group = "test-numba"},
108+
]
102109
dev = [
103110
{ include-group = "test"},
104111
{ include-group = "test-optional"},
112+
{ include-group = "test-numba"},
105113
]
106114

107115
[tool.hatch]

0 commit comments

Comments
 (0)