-
Notifications
You must be signed in to change notification settings - Fork 218
/
noxfile.py
80 lines (69 loc) · 2.47 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
import os
from pathlib import Path
import nox
nox.needs_version = ">=2024.4.15"
nox.options.default_venv_backend = "uv|virtualenv"
@nox.session
def update_python_dependencies(session):
"Update the base and per-python dependencies lockfiles"
if getattr(session.virtualenv, "venv_backend", "") != "uv":
session.install("uv>=0.1.23")
env = os.environ.copy()
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
# regenerate the constraints files
env["UV_CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
for python_minor in range(7, 14):
python_version = f"3.{python_minor}"
session.run(
"uv", "pip", "compile",
f"--python-version={python_version}",
"--generate-hashes",
"--no-strip-markers",
"requirements.in",
"--upgrade",
"--output-file",
f"docker/build_scripts/requirements{python_version}.txt",
env=env,
)
# tools
python_version = "3.12"
session.run(
"uv", "pip", "compile",
f"--python-version={python_version}",
"--generate-hashes",
"requirements-base-tools.in",
"--upgrade",
"--output-file",
"docker/build_scripts/requirements-base-tools.txt",
env=env,
)
tools = Path("requirements-tools.in").read_text().split("\n")
for tool in tools:
if tool.strip() == "":
continue
tmp_file = Path(session.create_tmp()) / f"{tool}.in"
tmp_file.write_text(f"{tool}\n")
session.run(
"uv", "pip", "compile",
f"--python-version={python_version}",
"--generate-hashes",
str(tmp_file),
"--upgrade",
"--output-file",
f"docker/build_scripts/requirements-tools/{tool}",
env=env,
)
@nox.session(python="3.12", reuse_venv=True)
def update_native_dependencies(session):
"Update the native dependencies"
script = "tools/update_native_dependencies.py"
deps = nox.project.load_toml(script)["dependencies"]
session.install(*deps)
session.run("python", script, *session.posargs)
@nox.session(python="3.12", reuse_venv=True)
def update_interpreters_download(session):
"Update all the Python interpreters"
script = "tools/update_interpreters_download.py"
deps = nox.project.load_toml(script)["dependencies"]
session.install(*deps)
session.run("python", script, *session.posargs)