-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathupdate-requirements.py
executable file
·34 lines (30 loc) · 1.18 KB
/
update-requirements.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
import subprocess
from packaging.requirements import Requirement
import tomllib
if __name__ == "__main__":
print("Parsing pyproject.toml for all direct project dependencies and optional dependencies.")
with open("pyproject.toml", "rb") as file:
pyproject = tomllib.load(file)
dependencies = pyproject["project"]["dependencies"]
dependencies += pyproject["project"]["optional-dependencies"]["testing"]
dependencies += pyproject["project"]["optional-dependencies"]["docs"]
dependencies += pyproject["project"]["optional-dependencies"]["cicd"]
# NOTE: see comment about build deps in pyproject.toml.
update_lines = [f"--upgrade-package={Requirement(dep).name}" for dep in dependencies]
cmd = [
"uv",
"pip",
"compile",
"--generate-hashes",
"--no-annotate",
"--no-emit-index-url",
"--no-emit-find-links",
"--no-header",
"--no-cache",
"--python-platform=x86_64-manylinux_2_31",
"--all-extras",
"pyproject.toml",
"--output-file=requirements.txt",
] + update_lines
print(f"Executing `{subprocess.list2cmdline(cmd)}`")
subprocess.run(cmd, check=True)