-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
103 lines (82 loc) · 2.53 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
from __future__ import annotations
import os
import nox
ROOT = os.path.dirname(os.path.abspath(__file__))
@nox.session
def build(session: nox.Session) -> None:
"""Build sdist and wheel dists."""
session.install("pip", "build")
session.install("setuptools")
session.run("python", "--version")
session.run("pip", "--version")
session.run("python", "-m", "build")
@nox.session
def install(session: nox.Session) -> None:
first_arg = session.posargs[0] if session.posargs else None
if first_arg:
if os.path.isfile(first_arg):
session.install(first_arg)
elif os.path.isdir(first_arg):
session.install(
"sensible_bmi", f"--find-links={first_arg}", "--no-deps", "--no-index"
)
else:
session.error("path must be a source distribution or folder")
else:
session.install(".")
@nox.session
def test(session: nox.Session) -> None:
"""Run the tests."""
session.install("-r", "requirements-testing.in", "-r", "requirements.in")
install(session)
session.run(
"coverage",
"run",
"--branch",
"--source=sensible_bmi,tests",
"--module",
"pytest",
)
session.run("coverage", "report", "--ignore-errors", "--show-missing")
session.run("coverage", "xml", "-o", "coverage.xml")
@nox.session
def lint(session: nox.Session) -> None:
"""Look for lint."""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")
@nox.session(name="docs-build")
def docs_build(session: nox.Session) -> None:
"""Build the docs."""
session.install("-r", "requirements-docs.in")
install(session)
os.makedirs("build", exist_ok=True)
docs_build_api(session)
session.run(
"sphinx-build",
*("-j", "auto"),
*("-b", "html"),
"-W",
"--keep-going",
"docs/",
"build/html",
)
session.log("generated docs at build/html")
@nox.session(name="docs-build-api")
def docs_build_api(session: nox.Session) -> None:
docs_dir = "docs/"
generated_dir = os.path.join(docs_dir, "generated", "api")
session.install(".", "-r", "requirements-docs.in")
session.log(f"generating api docs in {generated_dir}")
session.run(
"sphinx-apidoc",
"-e",
"-force",
"--no-toc",
"--module-first",
*("-d", "2"),
# f"--templatedir={docs_dir / '_templates'}",
*("-o", generated_dir),
"src/sensible_bmi",
"*.pyx",
"*.so",
)