-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathnoxfile.py
More file actions
95 lines (81 loc) · 3.05 KB
/
noxfile.py
File metadata and controls
95 lines (81 loc) · 3.05 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
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.stop_on_first_error = True
pyproject = nox.project.load_toml("pyproject.toml")
deps = nox.project.dependency_groups(pyproject, "test")
lint_deps = nox.project.dependency_groups(pyproject, "lint")
stubs_deps = nox.project.dependency_groups(pyproject, "stubs")
def install_rustworkx(session):
session.install(*deps)
session.install(".[all]", "-c", "constraints.txt")
# We define a common base such that -e test triggers a test with the current
# Python version of the interpreter and -e test_with_version launches
# a test with the specified version of Python.
def base_test(session):
install_rustworkx(session)
session.chdir("tests")
session.run("stestr", "run", *session.posargs)
@nox.session(python=["3"])
def test(session):
base_test(session)
@nox.session(python=["3.10", "3.11", "3.12", "3.13"])
def test_with_version(session):
base_test(session)
@nox.session(python=["3"])
def lint(session):
format(session)
typos(session)
session.install(*lint_deps)
session.run("ruff", "check", "rustworkx", "setup.py")
session.run("cargo", "fmt", "--all", "--", "--check", external=True)
session.run("python", "tools/find_stray_release_notes.py")
# For uv environments, we keep the virtualenvs separate to avoid conflicts
@nox.session(python=["3"], venv_backend="uv", reuse_venv=False, default=False)
def docs(session):
session.env["UV_PROJECT_ENVIRONMENT"] = session.virtualenv.location
session.env["UV_FROZEN"] = "1"
# faster build as generating docs already takes some time and we discard the env
session.env["SETUPTOOLS_RUST_CARGO_PROFILE"] = "dev"
session.run("uv", "sync", "--only-group", "docs")
session.install(".")
session.run(
"uv", "run", "--", "python", "-m", "ipykernel", "install", "--user"
)
session.run("uv", "run", "jupyter", "kernelspec", "list")
session.chdir("docs")
session.run(
"uv",
"run",
"sphinx-build",
"-W",
"-d",
"build/.doctrees",
"-b",
"html",
"source",
"build/html",
*session.posargs,
)
@nox.session(python=["3"], default=False)
def docs_clean(session):
session.chdir("docs")
session.run("rm", "-rf", "build", "source/apiref", external=True)
@nox.session(python=["3"])
def format(session):
session.install(*[d for d in lint_deps if "ruff" in d])
session.run("ruff", "format", "rustworkx", "tests", *session.posargs)
@nox.session(python=["3"])
def black(session):
# Legacy black formatting session is aliased
format(session)
@nox.session(python=["3"])
def typos(session):
session.install(*[d for d in lint_deps if "typos" in d])
session.run("typos", "--exclude", "releasenotes")
session.run("typos", "--no-check-filenames", "releasenotes")
@nox.session(python=["3"])
def stubs(session):
install_rustworkx(session)
session.install(*stubs_deps)
session.chdir("tests")
session.run("python", "-m", "mypy.stubtest", "--concise", "rustworkx", "--allowlist", "stubs_allowlist.txt")