Skip to content

Commit 0381602

Browse files
committed
WIP
1 parent 14f1bf4 commit 0381602

4 files changed

Lines changed: 16 additions & 47 deletions

File tree

action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ inputs:
77
required: true
88
default: "main"
99

10-
project_file_path:
11-
description: "The file to the project file that lists your dependencies. Defaults to 'pyproject.toml' Curretnly only pyproject.toml is supported but others may be added."
10+
project_file_name:
11+
description: "The filename to the project file that lists your dependencies, relative to the repository root. Defaults to 'pyproject.toml' Curretnly only pyproject.toml is supported but others may be added."
1212
required: false
1313
default: "pyproject.toml"
1414
token:

pyproject.toml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ platforms = ["linux-64"]
1717
[tool.pixi.feature.update.pypi-dependencies]
1818
spec_zero_tools = { path = ".", editable = true }
1919

20-
[tool.pixi.feature.update.tasks]
21-
update = { cmd = [
22-
"python",
23-
"update.py",
24-
"{{project_file_path}}",
25-
], args = [
26-
{ "arg" = "project_file_path", "default" = "pyproject.toml" },
27-
] }
28-
2920
[tool.pixi.feature.test.tasks]
3021
test = { cmd = ["pytest", "-vvv"] }
3122

@@ -39,9 +30,6 @@ tomlkit = ">=0.13.3,<0.14"
3930
pandas = "*"
4031
requests = "*"
4132

42-
[tool.pixi.feature.schedule.tasks]
43-
generate-schedule = { cmd = ["python", "spec_zero_tools/generate_schedule.py"] }
44-
4533
[tool.pixi.environments]
4634
dev = ["test", "schedule", "update"]
4735
schedule = ["schedule"]

spec_zero_tools/__init__.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from packaging.specifiers import SpecifierSet
22
from typing import Sequence, cast
3-
from pathlib import Path
43
import datetime
5-
from os import walk
64

75
from spec_zero_tools.versions import repr_spec_set, tighten_lower_bound
86
from spec_zero_tools.parsing import (
@@ -18,7 +16,7 @@
1816
from packaging.version import Version
1917

2018

21-
__all__ = ["read_schedule", "read_toml", "write_toml", "update_pyproject_toml", "discover_project_toml"]
19+
__all__ = ["read_schedule", "read_toml", "write_toml", "update_pyproject_toml"]
2220

2321
def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule):
2422
# iterate by idx because we want to update it inplace
@@ -115,29 +113,6 @@ def update_pyproject_toml(
115113
pyproject_data["project"]["dependencies"], new_version
116114
)
117115

118-
pixi_data = pyproject_data["tool"]["pixi"]
119-
update_pixi_dependencies(pixi_data, new_version)
120-
121-
def discover_project_toml(path: str | Path | None) -> Path:
122-
123-
if path is None:
124-
path = Path(".")
125-
elif isinstance(path, str):
126-
path = cast(Path, Path(path))
127-
128-
if path.is_file():
129-
130-
if path.exists():
131-
return path
132-
else:
133-
raise ValueError(f"{path} was supplied as path to project file but it did not exist")
134-
135-
136-
for root, _, files in walk(path):
137-
for file in files:
138-
if file == "pyproject.toml":
139-
return Path(root)/file
140-
141-
raise RuntimeError("Could not find a pyproject.toml")
142-
143-
116+
if "tool" in pyproject_data and "pixi" in pyproject_data['tool']:
117+
pixi_data = pyproject_data["tool"]["pixi"]
118+
update_pixi_dependencies(pixi_data, new_version)

update.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from spec_zero_tools import discover_project_toml, update_pyproject_toml, read_toml, write_toml, read_schedule
1+
from spec_zero_tools import update_pyproject_toml, read_toml, write_toml, read_schedule
2+
from pathlib import Path
23
from argparse import ArgumentParser
34

45

@@ -12,9 +13,14 @@
1213
parser.add_argument('toml_path', default="pyproject.toml", help="Path to the project file that lists the dependencies. defaults to 'pyproject.toml'.")
1314

1415
args = parser.parse_args()
15-
project_toml_path = discover_project_toml(args.toml_path)
16-
project_data = read_toml(project_toml_path)
16+
17+
toml_path = Path(args.toml_path)
18+
19+
if not toml_path.exists():
20+
raise ValueError(f"{toml_path} was supplied as path to project file but it did not exist")
21+
22+
project_data = read_toml(toml_path)
1723
schedule_data = read_schedule("schedule.json")
1824
update_pyproject_toml(project_data, schedule_data)
1925

20-
write_toml(project_toml_path, project_data)
26+
write_toml(toml_path, project_data)

0 commit comments

Comments
 (0)