-
Notifications
You must be signed in to change notification settings - Fork 15
/
noxfile.py
50 lines (41 loc) · 1.63 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
from pathlib import Path
import nox
requirements_directory = Path("requirements")
requirements_files = [
requirements_input_file_path.stem
for requirements_input_file_path in requirements_directory.glob("*.in")
]
@nox.session(name="pip-compile", python=["3.11"])
@nox.parametrize(["req"], arg_values_list=requirements_files, ids=requirements_files)
def pip_compile(session: nox.Session, req: str):
"""Generate lock files from input files or upgrade packages in lock files."""
# fmt: off
session.install(
"-r", str(requirements_directory / "pip-tools.in"),
"-c", str(requirements_directory / "pip-tools.txt"),
)
# fmt: on
# Use --upgrade by default unless a user passes -P.
upgrade_related_cli_flags = ("-P", "--upgrade-package", "--no-upgrade")
has_upgrade_related_cli_flags = any(
arg.startswith(upgrade_related_cli_flags) for arg in session.posargs
)
injected_extra_cli_args = () if has_upgrade_related_cli_flags else ("--upgrade",)
session.run(
"pip-compile",
"--output-file",
str(requirements_directory / f"{req}.txt"),
*session.posargs,
*injected_extra_cli_args,
str(requirements_directory / f"{req}.in"),
)
@nox.session(python=["3.11"]) # The python version should match the readthedocs configuration.
def build(session: nox.Session):
"""Generate HTML files for the Ansible docsite."""
# fmt: off
session.install(
"-r", str(requirements_directory / "requirements.in"),
"-c", str(requirements_directory / "requirements.txt"),
)
# fmt: on
session.run("python", "-I", "build.py", *session.posargs)