Skip to content

Commit e51f910

Browse files
committed
fix linter errors
1 parent 19020b2 commit e51f910

File tree

3 files changed

+30
-37
lines changed

3 files changed

+30
-37
lines changed

.spdx-ignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ requirements*.txt
1010
cuda_bindings/examples/*
1111

1212
# Vendored
13-
cuda_core/cuda/core/experimental/dlpack.h
13+
cuda_core/cuda/core/experimental/include/dlpack.h

ci/tools/merge_cuda_core_wheels.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
15
#!/usr/bin/env python3
26
"""
37
Script to merge CUDA-specific wheels into a single multi-CUDA wheel.
@@ -10,27 +14,27 @@
1014
that supports both CUDA versions, i.e., containing both `cuda/core/experimental/cu12`
1115
and `cuda/core/experimental/cu13`. At runtime, the code in `cuda/core/experimental/__init__.py`
1216
is used to import the appropriate CUDA-specific bindings.
17+
18+
This script is based on the one in NVIDIA/CCCL.
1319
"""
1420

1521
import argparse
1622
import os
1723
import shutil
18-
import subprocess
24+
import subprocess # nosec: B404
1925
import sys
2026
import tempfile
2127
from pathlib import Path
2228
from typing import List
2329

2430

25-
def run_command(
26-
cmd: List[str], cwd: Path = None, env: dict = None
27-
) -> subprocess.CompletedProcess:
31+
def run_command(cmd: List[str], cwd: Path = None, env: dict = os.environ) -> subprocess.CompletedProcess:
2832
"""Run a command with error handling."""
2933
print(f"Running: {' '.join(cmd)}")
3034
if cwd:
3135
print(f" Working directory: {cwd}")
3236

33-
result = subprocess.run(cmd, cwd=cwd, env=env, capture_output=True, text=True)
37+
result = subprocess.run(cmd, cwd=cwd, env=env, capture_output=True, text=True) # nosec: B603
3438

3539
if result.returncode != 0:
3640
print(f"Command failed with return code {result.returncode}")
@@ -77,9 +81,7 @@ def merge_wheels(wheels: List[Path], output_dir: Path) -> Path:
7781
break
7882

7983
if not extract_dir:
80-
raise RuntimeError(
81-
f"Could not find extracted wheel directory for {wheel.name}"
82-
)
84+
raise RuntimeError(f"Could not find extracted wheel directory for {wheel.name}")
8385

8486
# Rename to our expected name
8587
expected_name = temp_path / f"wheel_{i}"
@@ -95,11 +97,7 @@ def merge_wheels(wheels: List[Path], output_dir: Path) -> Path:
9597
# into the appropriate place in the base wheel
9698
for i, wheel_dir in enumerate(extracted_wheels):
9799
cuda_version = wheels[i].name.split(".cu")[1].split(".")[0]
98-
base_dir = (
99-
Path("cuda")
100-
/ "core"
101-
/ "experimental"
102-
)
100+
base_dir = Path("cuda") / "core" / "experimental"
103101
# Copy from other wheels
104102
print(f" Copying {wheel_dir} to {base_wheel}")
105103
shutil.copytree(wheel_dir / base_dir, base_wheel / base_dir / f"cu{cuda_version}")
@@ -151,15 +149,9 @@ def merge_wheels(wheels: List[Path], output_dir: Path) -> Path:
151149

152150
def main():
153151
"""Main merge script."""
154-
parser = argparse.ArgumentParser(
155-
description="Merge CUDA-specific wheels into a single multi-CUDA wheel"
156-
)
157-
parser.add_argument(
158-
"wheels", nargs="+", help="Paths to the CUDA-specific wheels to merge"
159-
)
160-
parser.add_argument(
161-
"--output-dir", "-o", default="dist", help="Output directory for merged wheel"
162-
)
152+
parser = argparse.ArgumentParser(description="Merge CUDA-specific wheels into a single multi-CUDA wheel")
153+
parser.add_argument("wheels", nargs="+", help="Paths to the CUDA-specific wheels to merge")
154+
parser.add_argument("--output-dir", "-o", default="dist", help="Output directory for merged wheel")
163155

164156
args = parser.parse_args()
165157

cuda_core/cuda/core/experimental/__init__.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
try:
66
import cuda.bindings
7-
except ImportError as e:
8-
raise ImportError("cuda.bindings 12.x or 13.x must be installed")
7+
except ImportError:
8+
raise ImportError("cuda.bindings 12.x or 13.x must be installed") from None
99
else:
1010
cuda_major, cuda_minor = cuda.bindings.__version__.split(".")[:2]
1111
if cuda_major not in ("12", "13"):
1212
raise ImportError("cuda.bindings 12.x or 13.x must be installed")
1313

1414
import importlib
15+
1516
subdir = f"cu{cuda_major}"
1617
try:
1718
verioned_mod = importlib.import_module(f".{subdir}", __package__)
@@ -25,29 +26,29 @@
2526
finally:
2627
del cuda.bindings, importlib, subdir, cuda_major, cuda_minor
2728

28-
from cuda.core.experimental import utils
29-
from cuda.core.experimental._device import Device
30-
from cuda.core.experimental._event import Event, EventOptions
31-
from cuda.core.experimental._graph import (
29+
from cuda.core.experimental import utils # noqa: E402
30+
from cuda.core.experimental._device import Device # noqa: E402
31+
from cuda.core.experimental._event import Event, EventOptions # noqa: E402
32+
from cuda.core.experimental._graph import ( # noqa: E402
3233
Graph,
3334
GraphBuilder,
3435
GraphCompleteOptions,
3536
GraphDebugPrintOptions,
3637
)
37-
from cuda.core.experimental._launch_config import LaunchConfig
38-
from cuda.core.experimental._launcher import launch
39-
from cuda.core.experimental._linker import Linker, LinkerOptions
40-
from cuda.core.experimental._memory import (
38+
from cuda.core.experimental._launch_config import LaunchConfig # noqa: E402
39+
from cuda.core.experimental._launcher import launch # noqa: E402
40+
from cuda.core.experimental._linker import Linker, LinkerOptions # noqa: E402
41+
from cuda.core.experimental._memory import ( # noqa: E402
4142
Buffer,
4243
DeviceMemoryResource,
4344
IPCChannel,
4445
LegacyPinnedMemoryResource,
4546
MemoryResource,
4647
)
47-
from cuda.core.experimental._module import Kernel, ObjectCode
48-
from cuda.core.experimental._program import Program, ProgramOptions
49-
from cuda.core.experimental._stream import Stream, StreamOptions
50-
from cuda.core.experimental._system import System
48+
from cuda.core.experimental._module import Kernel, ObjectCode # noqa: E402
49+
from cuda.core.experimental._program import Program, ProgramOptions # noqa: E402
50+
from cuda.core.experimental._stream import Stream, StreamOptions # noqa: E402
51+
from cuda.core.experimental._system import System # noqa: E402
5152

5253
system = System()
5354
__import__("sys").modules[__spec__.name + ".system"] = system

0 commit comments

Comments
 (0)