#!/usr/bin/env python3 """Neutralize vedastro SDK import-time PyPI upgrade. Fail the image build if the hook is missing.""" from __future__ import annotations import importlib.util import sys from pathlib import Path NOOP_SOURCE = 'def check_for_update(package_name="vedastro"):\n return None\n' def patch_update_check(path: Path) -> None: text = path.read_text(encoding="utf-8") if "def check_for_update" not in text: raise SystemExit(f"{path} does not define check_for_update") path.write_text(NOOP_SOURCE, encoding="utf-8") def main() -> int: spec = importlib.util.find_spec("vedastro.update_check") if spec is None or not spec.origin: print("vedastro.update_check is not installed", file=sys.stderr) return 1 path = Path(spec.origin) patch_update_check(path) print(f"neutralized {path}") return 0 if __name__ == "__main__": raise SystemExit(main())