|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +"""Check pixi cu13 cuda-version pins track ci/versions.yml (cuda.build.version).""" |
| 5 | + |
| 6 | +from __future__ import annotations |
| 7 | + |
| 8 | +import sys |
| 9 | +import tomllib |
| 10 | +from pathlib import Path |
| 11 | + |
| 12 | +import yaml |
| 13 | + |
| 14 | +ROOT = Path(__file__).resolve().parents[2] |
| 15 | +VERSIONS = ROOT / "ci" / "versions.yml" |
| 16 | +PIXI_FILES = [ROOT / d / "pixi.toml" for d in ("cuda_bindings", "cuda_core")] |
| 17 | + |
| 18 | + |
| 19 | +def main() -> int: |
| 20 | + if not VERSIONS.is_file(): |
| 21 | + print(f"error: {VERSIONS} not found", file=sys.stderr) |
| 22 | + return 2 |
| 23 | + try: |
| 24 | + build_version = yaml.safe_load(VERSIONS.read_text(encoding="utf-8"))["cuda"]["build"]["version"] |
| 25 | + except (KeyError, TypeError): |
| 26 | + print(f"error: cuda.build.version not found in {VERSIONS}", file=sys.stderr) |
| 27 | + return 2 |
| 28 | + |
| 29 | + major, minor, *_ = build_version.split(".") |
| 30 | + expected = f"{major}.{minor}.*" |
| 31 | + errors: list[str] = [] |
| 32 | + for path in PIXI_FILES: |
| 33 | + if not path.is_file(): |
| 34 | + print(f"error: {path} not found", file=sys.stderr) |
| 35 | + return 2 |
| 36 | + with path.open("rb") as f: |
| 37 | + data = tomllib.load(f) |
| 38 | + rel = path.relative_to(ROOT) |
| 39 | + try: |
| 40 | + variants = data["workspace"]["build-variants"]["cuda-version"] |
| 41 | + cu13 = data["feature"]["cu13"]["dependencies"]["cuda-version"] |
| 42 | + except KeyError as exc: |
| 43 | + print(f"error: {rel} missing cuda-version key: {exc}", file=sys.stderr) |
| 44 | + return 2 |
| 45 | + if expected not in variants: |
| 46 | + errors.append(f"{rel}: build-variants missing {expected!r} (has {variants})") |
| 47 | + if cu13 != expected: |
| 48 | + errors.append(f"{rel}: cu13 pin is {cu13!r}, expected {expected!r}") |
| 49 | + |
| 50 | + if errors: |
| 51 | + print(f"error: pixi cuda-version pins out of sync (expected {expected!r}):", file=sys.stderr) |
| 52 | + for err in errors: |
| 53 | + print(f" - {err}", file=sys.stderr) |
| 54 | + return 1 |
| 55 | + |
| 56 | + print(f"OK: pixi cuda-version pins match ci/versions.yml ({expected!r})") |
| 57 | + return 0 |
| 58 | + |
| 59 | + |
| 60 | +if __name__ == "__main__": |
| 61 | + sys.exit(main()) |
0 commit comments