Skip to content

Commit c46fd38

Browse files
committed
chore: new nox, pytest-xdist
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 05b2d51 commit c46fd38

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

noxfile.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1+
# /// script
2+
# dependencies = ["nox>=2025.2.9"]
3+
# ///
4+
15
from __future__ import annotations
26

37
import argparse
48
from typing import Any
59

610
import nox
711

8-
nox.needs_version = ">=2024.4.15"
12+
nox.needs_version = ">=2025.2.9"
913
nox.options.default_venv_backend = "uv|virtualenv"
1014

1115

12-
def _get_group(name: str, groups: dict[str, Any]) -> list[str]:
13-
group = groups[name]
14-
return [d if isinstance(d, str) else _get_group(d, groups) for d in group]
15-
16-
17-
def dependency_groups(pyproject: dict[str, Any], *names: str) -> list[str]:
18-
groups = pyproject["dependency-groups"]
19-
return [item for name in names for item in _get_group(name, groups)]
20-
21-
2216
@nox.session
2317
def tests(session: nox.Session) -> None:
2418
"""
@@ -27,26 +21,28 @@ def tests(session: nox.Session) -> None:
2721
opts = (
2822
["--reinstall-package=boost-histogram"] if session.venv_backend == "uv" else []
2923
)
24+
args = session.posargs or ["-n", "auto"]
3025
pyproject = nox.project.load_toml("pyproject.toml")
31-
session.install(*dependency_groups(pyproject, "test"))
26+
session.install(*nox.project.dependency_groups(pyproject, "test"))
3227
session.install("-v", ".", *opts, silent=False)
33-
session.run("pytest", *session.posargs)
28+
session.run("pytest", *args)
3429

3530

3631
@nox.session(default=False)
3732
def hist(session: nox.Session) -> None:
3833
"""
3934
Run Hist's test suite
4035
"""
36+
args = session.posargs or ["-n", "auto"]
4137
pyproject = nox.project.load_toml("pyproject.toml")
4238
session.install(".")
4339
tmpdir = session.create_tmp()
4440
session.chdir(tmpdir)
4541
session.run("git", "clone", "https://github.com/scikit-hep/hist", external=True)
4642
session.chdir("hist")
47-
session.install(".", *dependency_groups(pyproject, "test", "plot"))
43+
session.install(".", *nox.project.dependency_groups(pyproject, "test", "plot"))
4844
session.run("pip", "list")
49-
session.run("pytest", *session.posargs)
45+
session.run("pytest", *args)
5046

5147

5248
@nox.session(reuse_venv=True, default=False)
@@ -64,7 +60,7 @@ def docs(session: nox.Session) -> None:
6460
serve = args.builder == "html" and session.interactive
6561

6662
extra_installs = ["sphinx-autobuild"] if serve else []
67-
session.install(*dependency_groups(pyproject, "docs"), *extra_installs)
63+
session.install(*nox.project.dependency_groups(pyproject, "docs"), *extra_installs)
6864

6965
shared_args = (
7066
"-n", # nitpicky mode
@@ -89,7 +85,7 @@ def build_api_docs(session: nox.Session) -> None:
8985
"""
9086
pyproject = nox.project.load_toml("pyproject.toml")
9187

92-
session.install(*dependency_groups(pyproject, "docs"))
88+
session.install(*nox.project.dependency_groups(pyproject, "docs"))
9389
session.run(
9490
"sphinx-apidoc",
9591
"-o",
@@ -129,5 +125,9 @@ def make_pickle(session: nox.Session) -> None:
129125
Make a pickle file for this version
130126
"""
131127
pyproject = nox.project.load_toml("pyproject.toml")
132-
session.install(".", *dependency_groups(pyproject, "dev"))
128+
session.install(".", *nox.project.dependency_groups(pyproject, "dev"))
133129
session.run("python", "tests/pickles/make_pickle.py", *session.posargs)
130+
131+
132+
if __name__ == "__main__":
133+
nox.main()

pyproject.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ test = [
9090
"hypothesis>=6.0",
9191
"pytest-benchmark",
9292
"pytest>=6.0",
93+
"pytest-xdist",
9394
]
9495

9596

@@ -161,13 +162,14 @@ ignore_missing_imports = true
161162
[tool.cibuildwheel]
162163
build-frontend = "build[uv]"
163164
test-groups = ["test"]
164-
test-command = "pytest --benchmark-disable {project}/tests"
165+
test-command = "pytest -n auto --benchmark-disable {project}/tests"
165166
skip = [
166167
"pp38-*",
167168
]
168169
test-skip = [
169170
"cp*-musllinux_*", # Segfaults
170171
"cp313t-*win*",
172+
"pp311-*", # no numpy wheels
171173
]
172174
enable = ["cpython-freethreading", "pypy"]
173175
environment-pass = ["SETUPTOOLS_SCM_PRETEND_VERSION"]

0 commit comments

Comments
 (0)