Skip to content

Commit

Permalink
ENH: Track outdated allows in recipe (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Aug 14, 2024
1 parent 955ea06 commit 3e73bcb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
8 changes: 4 additions & 4 deletions recipes/mne-python/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ specs:
- pytest-timeout =2.3.1
- pre-commit =3.8.0
- ruff =0.5.7
- uv =0.2.35
- uv =0.2.36
- check-manifest =0.49.0
- codespell =2.3.0
- py-spy =0.3.14
Expand All @@ -192,21 +192,21 @@ specs:
- hatchling =1.25.0
- hatch-vcs =0.4.0
- mypy =1.11.1
- towncrier =23.11.0
- towncrier =23.11.0 # allow_outdated, 24.7.1 doesn't work with sphinxcontrib-towncrier
- vulture =2.11
# Doc building
- numpydoc =1.8.0
- pydata-sphinx-theme =0.15.4
- graphviz =12.0.0
- python-graphviz =0.20.3
- selenium =4.23.1
- sphinx =7.4.7
- sphinx =7.4.7 # allow_outdated, sphinx-design not 8.0 compatible
- sphinx-design =0.6.1
- sphinx-gallery =0.17.1
- sphinxcontrib-bibtex =2.6.2
- sphinx-copybutton =0.5.2
- sphinxcontrib-youtube =1.4.1
- intersphinx-registry =0.2406.4
- intersphinx-registry =0.2408.13
# OS-specific
- git =2.46.0 # [win]
- make =4.3 # [win]
Expand Down
35 changes: 26 additions & 9 deletions tests/test_outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ def _cache(fun):

recipe_dir = Path(__file__).parents[1] / "recipes" / "mne-python"
construct_yaml_path = recipe_dir / "construct.yaml"
print(f"Analyzing spec file: {construct_yaml_path}\n")

recipe = construct_yaml_path.read_text(encoding="utf-8")
construct_yaml = yaml.safe_load(recipe)
specs = construct_yaml["specs"]
lines = [line.strip() for line in recipe.splitlines()]
lines = [
line
for line in lines[lines.index("specs:") + 1 : lines.index("condarc:")]
if line and not line.startswith("#")
]
for line in lines:
assert line.startswith("- "), f"Line does not start with '- ': {line=}"
lines = [line[2:] for line in lines]
specs = yaml.safe_load(recipe)["specs"]
assert len(specs) == len(lines), f"{len(specs)=} != {len(lines)=}"
LJUST = 25

print(f"Analyzing spec file: {construct_yaml_path}\n")


@dataclass()
class Package: # noqa: D101
Expand All @@ -38,13 +47,18 @@ class Package: # noqa: D101
version_conda_forge: str | None = None


allowed_outdated: set[str] = {
"sphinx", # sphinx-design not compatible
"towncrier", # doesn't work with
}
allowed_outdated: set[str] = set()
packages: list[Package] = []

for spec in specs:
for line, spec in zip(lines, specs):
if "#" in line:
line_spec, comment = line.split("#", maxsplit=1)
line_spec = line_spec.strip()
else:
line_spec, comment = line, ""
assert line_spec == spec, f"{line_spec=} != {spec=}"
del line_spec

if " " in spec:
assert spec.count(" ") == 1, f"Wrong number of spaces in spec: {spec}"
name, version = spec.split(" ")
Expand All @@ -57,6 +71,9 @@ class Package: # noqa: D101
name = spec
version = None

if "allow_outdated" in comment:
allowed_outdated.add(name)

packages.append(Package(name=name, version_spec=version))
del name, version

Expand Down

0 comments on commit 3e73bcb

Please sign in to comment.