Skip to content

Commit 3d6a824

Browse files
committed
Add PEP723 metadata to cuda_core examples
1 parent a7670b6 commit 3d6a824

15 files changed

+114
-14
lines changed

.github/workflows/test-wheel-linux.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ jobs:
9696
uses: nv-gha-runners/setup-proxy-cache@main
9797
continue-on-error: true
9898

99+
- name: Install uv
100+
uses: astral-sh/setup-uv@v7
101+
99102
- name: Install dependencies
100103
uses: ./.github/actions/install_unix_deps
101104
continue-on-error: false
@@ -277,6 +280,11 @@ jobs:
277280
LOCAL_CTK: ${{ matrix.LOCAL_CTK }}
278281
run: run-tests core
279282

283+
- name: Run cuda.core examples with PEP 723 metadata in isolation
284+
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }}
285+
run: |
286+
ci/tools/run-examples-pep723 cuda_core/examples/
287+
280288
- name: Ensure cuda-python installable
281289
run: |
282290
if [[ "${{ matrix.LOCAL_CTK }}" == 1 ]]; then

ci/tools/run-examples-pep723

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Runs a directory of examples using `uv run` to test that the PEP 723
7+
# dependency metadata in them is valid.
8+
9+
# We allow a resolution to fail for cuda_core or cuda_bindings only, since there
10+
# we assume it is pinned to some future release. This allows examples to be
11+
# written for unreleased features. Testing examples against prereleases is
12+
# already covered by CI elsewhere.
13+
14+
TARGET_DIR=$1
15+
16+
if [ -z "$TARGET_DIR" ]; then
17+
echo "Usage: $0 <directory>"
18+
exit 1
19+
fi
20+
21+
FAILED=0
22+
23+
while IFS= read -r -d '' file; do
24+
echo "Running $file..."
25+
OUTPUT=$(uv run "$file" 2>&1)
26+
EXIT_CODE=$?
27+
28+
if [ $EXIT_CODE -ne 0 ]; then
29+
if echo "$OUTPUT" | grep -Eq "Because only cuda-(core|bindings)"; then
30+
echo "SKIPPED: $file (No solution found)"
31+
else
32+
echo "FAILED: $file"
33+
echo "$OUTPUT"
34+
FAILED=1
35+
fi
36+
else
37+
echo "PASSED: $file"
38+
fi
39+
done < <(find "$TARGET_DIR" -name "*.py" -print0)
40+
41+
if [ $FAILED -ne 0 ]; then
42+
exit 1
43+
fi

cuda_core/examples/cuda_graphs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -10,6 +10,10 @@
1010
#
1111
# ################################################################################
1212

13+
# /// script
14+
# dependencies = ["cuda_bindings", "cuda_core", "cupy"]
15+
# ///
16+
1317
import sys
1418
import time
1519

cuda_core/examples/gl_interop_plasma.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
# effect popular in the demoscene). The window title shows the current FPS.
5454
# Close the window or press Escape to exit.
5555
#
56-
# Requirements
57-
# ============
58-
# pip install pyglet
56+
57+
# /// script
58+
# dependencies = ["cuda_bindings", "cuda_core>0.6.0", "pyglet"]
59+
# ///
5960

6061
import ctypes
6162
import sys

cuda_core/examples/jit_lto_fractal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -12,6 +12,10 @@
1212
#
1313
# ################################################################################
1414

15+
# /// script
16+
# dependencies = ["cuda_bindings", "cuda_core", "cupy"]
17+
# ///
18+
1519
import argparse
1620
import sys
1721

cuda_core/examples/memory_ops.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -10,6 +10,10 @@
1010
#
1111
# ################################################################################
1212

13+
# /// script
14+
# dependencies = ["cuda_bindings", "cuda_core", "cupy", "numpy"]
15+
# ///
16+
1317
import sys
1418

1519
import cupy as cp

cuda_core/examples/pytorch_example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core", "torch"]
14+
# ///
15+
1216
import sys
1317

1418
import torch

cuda_core/examples/saxpy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -10,6 +10,10 @@
1010
#
1111
# ################################################################################
1212

13+
# /// script
14+
# dependencies = ["cuda_bindings", "cuda_core", "cupy"]
15+
# ///
16+
1317
import sys
1418

1519
import cupy as cp

cuda_core/examples/show_device_properties.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core"]
14+
# ///
15+
1216
import sys
1317

1418
from cuda.core import Device, system

cuda_core/examples/simple_multi_gpu_example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core", "cupy"]
14+
# ///
15+
1216
import sys
1317

1418
import cupy as cp

0 commit comments

Comments
 (0)