forked from Qiskit/rustworkx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
78 lines (65 loc) · 2.23 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
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.stop_on_first_error = True
deps = [
"setuptools-rust",
"fixtures",
"testtools>=2.5.0",
"networkx>=2.5",
"scipy>=1.7",
"stestr>=4.1",
]
lint_deps = [
"black~=22.0",
"ruff~=0.1",
"setuptools-rust",
]
stubs_deps = [
"mypy==1.8.0",
"typing-extensions",
]
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("python", "-m", "unittest", "discover", *session.posargs)
@nox.session(python=["3"])
def test(session):
base_test(session)
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
def test_with_version(session):
base_test(session)
@nox.session(python=["3"])
def lint(session):
black(session)
session.install(*lint_deps)
session.run("ruff", "check", "rustworkx", "retworkx", "setup.py")
session.run("cargo", "fmt", "--all", "--", "--check", external=True)
session.run("python", "tools/find_stray_release_notes.py")
@nox.session(python=["3"])
def docs(session):
install_rustworkx(session)
session.install("-r", "docs/source/requirements.txt", "-c", "constraints.txt")
session.run("python", "-m", "ipykernel", "install", "--user")
session.run("jupyter", "kernelspec", "list")
session.chdir("docs")
session.run("sphinx-build", "-W", "-d", "build/.doctrees", "-b", "html", "source", "build/html", *session.posargs)
@nox.session(python=["3"])
def docs_clean(session):
session.chdir("docs")
session.run("rm", "-rf", "build", "source/apiref", external=True)
@nox.session(python=["3"])
def black(session):
session.install(*[d for d in lint_deps if "black" in d])
session.run("black", "rustworkx", "tests", "retworkx", *session.posargs)
@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")