Skip to content

Commit 00588e1

Browse files
committed
Got initial version to address issue 2183. Let pre-commit check covers pixi cuda version pins to ci/versions.yml
1 parent 76bac4e commit 00588e1

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ repos:
5050
files: ^cuda_bindings/
5151
types: [text]
5252

53+
- id: check-pixi-cuda-version
54+
name: Check pixi cuda-version pins track ci/versions.yml
55+
entry: python ./ci/tools/check_pixi_cuda_version.py
56+
language: python
57+
additional_dependencies: [pyyaml]
58+
files: '^(ci/versions\.yml|cuda_bindings/pixi\.toml|cuda_core/pixi\.toml)$'
59+
pass_filenames: false
60+
5361
- id: no-markdown-in-docs-source
5462
name: Prevent markdown files in docs/source directories
5563
entry: bash -c
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)