Files
computer-playbook/cli/contributing/update/pip/__main__.py
kevinveenbirkenbachandClaude Opus 5 5e6884b16d feat(update): keep pinned pip requirements from ageing unnoticed
The version cron updates docker image tags and repository refs, and tests/external/update covers docker, addons and repository. Neither sees a version inside an Ansible task variable, and dependabot reads pyproject.toml rather than roles/. A pin set once therefore froze and nothing thawed it: backup-docker-to-local has not moved since it was written, and the automtu pin one commit back would have gone the same way.

utils/update/pip mirrors the docker module: collect the pins, ask PyPI, rewrite in place. Only exact == pins are collected, because a range or a VCS reference states an intent an updater must not overrule. The external check warns rather than fails, like its docker sibling, so a slow PyPI cannot redden a run and a release the repository has deliberately not taken is not a regression.

The cron job is the docker job with one script swapped, so a changed pin arrives as its own PR under update/pip-pins.

Executed: the collector finds both pins in the repository; a synthetic file rewrites from 1.0.0 to 1.1.1 with the indent, quoting and neighbouring line untouched; automtu==1.0.0 would be reported while a bare name and a git+ reference are passed over.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 01:44:51 +02:00

60 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
from __future__ import annotations
import argparse
from pathlib import Path
from utils.update.pip import apply_updates, find_outdated_updates
from . import PROJECT_ROOT
def main() -> int:
parser = argparse.ArgumentParser(
description="Update exact pip pins in roles/**/*.yml to their latest release."
)
parser.add_argument(
"--repo-root",
type=Path,
default=PROJECT_ROOT,
help="Repository root to scan and update",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Print planned updates without modifying files",
)
args = parser.parse_args()
repo_root = args.repo_root.resolve()
updates = find_outdated_updates(repo_root)
if not updates:
print("Pinned pip requirements are already up to date.")
return 0
print("Planned pip pin updates:")
for update in updates:
rel_path = update.entry.config_path.relative_to(repo_root)
print(
f"- {rel_path}:{update.entry.line_number} "
f"{update.entry.package} {update.entry.version} -> {update.latest}"
)
if args.dry_run:
return 0
changed_paths = apply_updates(updates)
if changed_paths:
print("\nUpdated files:")
for path in changed_paths:
print(f"- {path.relative_to(repo_root)}")
else:
print("\nNo files changed.")
return 0
if __name__ == "__main__":
raise SystemExit(main())