Repository navigation
Expand file tree
/
Copy pathrun_spec0_update.py
More file actions
60 lines (58 loc) · 2.24 KB
/
Copy pathrun_spec0_update.py
File metadata and controls
60 lines (58 loc) · 2.24 KB
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
from argparse import ArgumentParser
from pathlib import Path
from spec0_action import read_schedule, read_toml, update_pyproject_toml, write_toml
if __name__ == "__main__":
parser = ArgumentParser(
description="A script to update your project dependencies to be in line with the scientific python SPEC 0 support schedule",
)
parser.add_argument(
"toml_path",
default="pyproject.toml",
help="Path to the project file that lists the dependencies. defaults to 'pyproject.toml'.",
)
parser.add_argument(
"schedule_path",
default="schedule.json",
help="Path to the schedule json payload. defaults to 'schedule.json'",
)
parser.add_argument(
"--update-all",
type=float,
default=None,
metavar="YEARS",
help="Update PEP dependencies without an applicable schedule floor or explicit core-package support period to versions first released within the last YEARS years (e.g., 2).",
)
parser.add_argument(
"--spec0-support-years",
type=float,
default=None,
metavar="YEARS",
help="Compute SPEC 0 core-package floors from PyPI using YEARS of support; Python still follows the supplied schedule.",
)
parser.add_argument(
"--excluded-packages",
default="",
metavar="NAMES",
help="Leave these comma- or whitespace-separated package names unchanged; use python to exclude Python requirements.",
)
args = parser.parse_args()
toml_path = Path(args.toml_path)
schedule_path = Path(args.schedule_path)
if not toml_path.exists():
raise ValueError(
f"{toml_path} was supplied as path to project file but it did not exist"
)
if not schedule_path.exists():
raise ValueError(
f"{schedule_path} was supplied as path to schedule file but it did not exist"
)
project_data = read_toml(toml_path)
schedule_data = read_schedule(schedule_path)
update_pyproject_toml(
project_data,
schedule_data,
update_all=args.update_all,
spec0_support_years=args.spec0_support_years,
excluded_packages=args.excluded_packages.replace(",", " ").split(),
)
write_toml(toml_path, project_data)