Skip to content

Commit f1ef076

Browse files
committed
build: produce actionable error when cuda namespace is entirely absent
Made-with: Cursor
1 parent 6facaa5 commit f1ef076

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

cuda_bindings/build_hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ def _import_get_cuda_path_or_home():
4242
try:
4343
import cuda.pathfinder
4444
except ModuleNotFoundError as exc:
45-
if exc.name != "cuda.pathfinder":
45+
if exc.name not in ("cuda", "cuda.pathfinder"):
4646
raise
4747
from importlib.metadata import PackageNotFoundError, distribution
4848
from pathlib import Path
4949

50-
import cuda
51-
5250
try:
5351
dist = distribution("cuda-pathfinder")
5452
except PackageNotFoundError:
5553
raise ModuleNotFoundError(
5654
"cuda-pathfinder is not installed in the build environment. "
5755
"Ensure 'cuda-pathfinder>=1.5' is in build-system.requires."
5856
) from None
57+
import cuda
58+
5959
site_cuda = str(dist.locate_file(Path("cuda")))
6060
cuda_paths = list(cuda.__path__)
6161
if site_cuda not in cuda_paths:

cuda_core/build_hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ def _import_get_cuda_path_or_home():
3737
try:
3838
import cuda.pathfinder
3939
except ModuleNotFoundError as exc:
40-
if exc.name != "cuda.pathfinder":
40+
if exc.name not in ("cuda", "cuda.pathfinder"):
4141
raise
4242
from importlib.metadata import PackageNotFoundError, distribution
4343
from pathlib import Path
4444

45-
import cuda
46-
4745
try:
4846
dist = distribution("cuda-pathfinder")
4947
except PackageNotFoundError:
5048
raise ModuleNotFoundError(
5149
"cuda-pathfinder is not installed in the build environment. "
5250
"Ensure 'cuda-pathfinder>=1.5' is in build-system.requires."
5351
) from None
52+
import cuda
53+
5454
site_cuda = str(dist.locate_file(Path("cuda")))
5555
cuda_paths = list(cuda.__path__)
5656
if site_cuda not in cuda_paths:

0 commit comments

Comments
 (0)