-
Notifications
You must be signed in to change notification settings - Fork 79
/
noxfile.py
107 lines (84 loc) · 2.96 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
Noxfile for iminuit.
Pass extra arguments to pytest after --
"""
import nox
import sys
sys.path.append(".")
import python_releases
nox.needs_version = ">=2024.3.2"
nox.options.default_venv_backend = "uv|virtualenv"
ENV = {
"JUPYTER_PLATFORM_DIRS": "1", # Hides warnings in Jupyter
"COVERAGE_CORE": "sysmon", # faster coverage on Python 3.12
}
PYPROJECT = nox.project.load_toml("pyproject.toml")
MINIMUM_PYTHON = PYPROJECT["project"]["requires-python"].strip(">=")
LATEST_PYTHON = str(python_releases.latest())
nox.options.sessions = ["test", "mintest", "maxtest"]
@nox.session(reuse_venv=True)
def test(session: nox.Session) -> None:
"""Run all tests."""
session.install("--only-binary=:all:", "-e.[test]")
extra_args = session.posargs if session.posargs else ("-n=auto",)
session.run("pytest", *extra_args, env=ENV)
@nox.session(python=MINIMUM_PYTHON, venv_backend="uv")
def mintest(session: nox.Session) -> None:
"""Run tests on the minimum python version."""
session.install("--only-binary=:all:", "-e.", "--resolution=lowest-direct")
session.install("pytest", "pytest-xdist")
extra_args = session.posargs if session.posargs else ("-n=auto",)
session.run("pytest", *extra_args)
@nox.session(python=LATEST_PYTHON)
def maxtest(session: nox.Session) -> None:
"""Run the unit and regular tests."""
session.install(
"--only-binary=:all:",
"-e.",
"scipy",
"matplotlib",
"pytest",
"pytest-xdist",
"--pre",
)
extra_args = session.posargs if session.posargs else ("-n=auto",)
session.run("pytest", *extra_args, env=ENV)
@nox.session(python="pypy3.9")
def pypy(session: nox.Session) -> None:
"""Run the unit and regular tests."""
session.install("-e.")
session.install("pytest", "pytest-xdist")
session.run("pytest", "-n=auto", *session.posargs)
# Python-3.12 provides coverage info faster
@nox.session(python="3.12", venv_backend="uv", reuse_venv=True)
def cov(session: nox.Session) -> None:
"""Run covage and place in 'htmlcov' directory."""
session.install("--only-binary=:all:", "-e.[test,doc]")
session.run("coverage", "run", "-m", "pytest", env=ENV)
session.run("coverage", "html", "-d", "build/htmlcov")
session.run("coverage", "report", "-m")
# 3.11 needed by Cython notebook
@nox.session(python="3.11", reuse_venv=True)
def doc(session: nox.Session) -> None:
"""Build html documentation."""
session.install("--only-binary=:all:", "-e.[test,doc]")
# link check
session.run(
"sphinx-build",
"-T", # full tracebacks
"-v",
"-b=html",
"doc",
"build/html",
)
@nox.session(python="3.11", reuse_venv=True)
def links(session: nox.Session) -> None:
"""Check all links in the documentation."""
session.install("--only-binary=:all:", "-e.[test,doc]")
# link check
session.run(
"sphinx-build",
"-b=linkcheck",
"doc",
"build/html",
)