|
| 1 | +# /// script |
| 2 | +# dependencies = ["nox >= 2025.2.9", "packaging"] |
| 3 | +# /// |
1 | 4 | """Nox configuration.""" |
2 | 5 |
|
3 | | -import re |
4 | | -from typing import Any |
5 | | - |
6 | 6 | import nox |
| 7 | +from nox.project import load_toml as load_pyproject_toml |
| 8 | +from nox.project import python_versions as get_python_versions |
7 | 9 | from nox.sessions import Session |
| 10 | +from packaging.version import Version |
8 | 11 |
|
9 | | -nox.needs_version = ">=2024.3.2" |
| 12 | +# Keep nox.needs_version in sync with: |
| 13 | +# * pyproject.toml, |
| 14 | +# * the inline metadata above. |
| 15 | +nox.needs_version = ">= 2025.2.9" |
10 | 16 | nox.options.default_venv_backend = "uv" |
11 | 17 | nox.options.error_on_missing_interpreters = True |
12 | 18 | nox.options.error_on_external_run = True |
13 | 19 |
|
14 | | - |
15 | | -def version_tuple(version: str) -> tuple[int, ...]: |
16 | | - """'1.24' --> (1, 24).""" |
17 | | - return tuple(int(s) for s in version.split(".")) |
18 | | - |
19 | | - |
20 | | -def get_python_versions(pyproject: dict[str, Any]) -> list[str]: |
21 | | - """Extract a sorted list of supported Python versions from the Trove classifiers.""" |
22 | | - classifiers = pyproject["project"]["classifiers"] |
23 | | - match_classifier = re.compile( |
24 | | - r"Programming Language :: Python :: (?P<version>\d+\.\d+)" |
25 | | - ).fullmatch |
26 | | - python_versions = [ |
27 | | - m.group("version") |
28 | | - for classifier in classifiers |
29 | | - if (m := match_classifier(classifier)) |
30 | | - ] |
31 | | - return sorted(python_versions, key=version_tuple) |
32 | | - |
33 | | - |
34 | | -pyproject = nox.project.load_toml("pyproject.toml") |
35 | | -python_versions = get_python_versions(pyproject) |
36 | | -# 2025-04-08 Pandas does not run neither on PyPy, nor on free-threaded CPython. |
37 | | -more_python_versions = [] |
| 20 | +pyproject = load_pyproject_toml() |
| 21 | +# Waiting for nox to take care of sorting. |
| 22 | +# https://github.com/wntrblm/nox/issues/1074 |
| 23 | +python_versions = sorted(get_python_versions(pyproject), key=Version) |
| 24 | +# 2026-03-20 Pandas does not run on PyPy. |
| 25 | +more_python_versions = ["3.13t", "3.14t"] |
38 | 26 | oldest_deps = [ |
39 | 27 | spec.replace(">=", "==") for spec in pyproject["project"]["dependencies"] |
40 | 28 | ] |
|
0 commit comments