forked from civisanalytics/python-glmnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnoxfile.py
More file actions
executable file
·101 lines (86 loc) · 2.92 KB
/
noxfile.py
File metadata and controls
executable file
·101 lines (86 loc) · 2.92 KB
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
import os
import sys
from pathlib import Path
import nox
PACKAGE = "glmnet"
PYTHON_VERSIONS = ["3.10", "3.11", "3.12", "3.13"] # no 3.9 because sweet christmas does it want to fail to install
LATEST_VERSION = PYTHON_VERSIONS[-2] # since 3.13 isn't *officially* released yet
NUMPY_VERSIONS = ["2.1.3", "2.0.2", "1.26.4", "1.25.2", "1.24.4"]
os.environ.update(
{
"PDM_IGNORE_SAVED_PYTHON": "1",
"PDM_IGNORE_ACTIVE_VENV": "0",
}
)
nox.needs_version = ">=2024.4.15"
nox.options.sessions = (
"mypy",
"tests",
)
locations = (
"src",
"tests",
)
@nox.session(python=LATEST_VERSION, reuse_venv=True)
def lockfile(session) -> None:
"""Run the test suite."""
session.run_always("pdm", "lock", external=True)
@nox.session(python=LATEST_VERSION)
def lint(session) -> None:
"""Lint using ruff."""
args = session.posargs or locations
session.install("ruff")
session.run("ruff", "check", "--fix", *args)
session.run("ruff", "format", *args)
@nox.session(python=LATEST_VERSION, reuse_venv=False)
def mypy(session) -> None:
"""Type-check using mypy."""
session.install("mypy")
session.install(".", external=True)
session.run(
"mypy",
"--install-types",
"--non-interactive",
f"--python-executable={sys.executable}",
"noxfile.py",
)
@nox.session()
# numpy >=2.1 requires python 3.10-3.13
@nox.parametrize(
"python,numpy",
[ (python, numpy)
for python in PYTHON_VERSIONS
for numpy in NUMPY_VERSIONS
if (python, numpy) not in [
# ("3.9", "2.1.3"),
# ("3.9", "2.0.2"),
("3.12", "1.25.2"),
("3.12", "1.24.4"),
("3.13", "1.25.2"),
("3.13", "1.24.4")
]
]
)
def tests(session, numpy) -> None:
"""Run the test suite."""
# session.install("pdm")
# session.run("pdm", "lock")
session.install("cython", f"numpy=={numpy}")
session.install("meson-python", "ninja", "setuptools")
session.install("pytest>=8.3.3","pytest-lazy-fixtures>=1.1.1","pytest-randomly>=3.16.0","pytest-xdist[psutil]>=3.6.1", "coverage[toml]")
session.install(".", external=True)
session.run("python", "-c", "'import numpy; print(numpy.__version__)'")
session.run(
# running in parallel doesn't work I think because of not setting a seed
# "coverage", "run", "--parallel", "-m", "pytest", "--numprocesses", "auto", "--random-order", external=True
"coverage", "run", "-m", "pytest", "tests"
)
@nox.session(python=LATEST_VERSION, reuse_venv=True)
def coverage(session) -> None:
"""Produce the coverage report."""
args = session.posargs or ["report"]
session.install("coverage[toml]", "codecov", external=True)
if not session.posargs and any(Path().glob(".coverage.*")):
session.run("coverage", "combine")
session.run("coverage", "json", "--fail-under=0")
session.run("codecov", *args)