Skip to content

Commit 3cb0313

Browse files
committed
build: diagnostic for importlib.metadata locate_file in PEP 517 builds
Made-with: Cursor
1 parent f1ef076 commit 3cb0313

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

cuda_bindings/build_hooks.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,27 @@ def _import_get_cuda_path_or_home():
5656
) from None
5757
import cuda
5858

59-
site_cuda = str(dist.locate_file(Path("cuda")))
59+
locate_result = str(dist.locate_file(Path("cuda")))
60+
print(f"[diag] dist._path: {dist._path}", flush=True)
61+
print(f"[diag] dist._path.parent: {dist._path.parent}", flush=True)
62+
print(f"[diag] locate_file('cuda'): {locate_result}", flush=True)
63+
print(f"[diag] locate_file exists: {os.path.isdir(locate_result)}", flush=True)
64+
print(
65+
f"[diag] locate_file/pathfinder exists: {os.path.isdir(os.path.join(locate_result, 'pathfinder'))}",
66+
flush=True,
67+
)
68+
print(f"[diag] cuda.__path__ (before): {cuda.__path__}", flush=True)
69+
print("[diag] sys.path:", flush=True)
70+
for p in sys.path:
71+
sp_cuda = os.path.join(p, "cuda")
72+
has_pf = os.path.isdir(os.path.join(sp_cuda, "pathfinder"))
73+
print(f"[diag] {p} -> cuda/pathfinder exists: {has_pf}", flush=True)
74+
75+
site_cuda = locate_result
6076
cuda_paths = list(cuda.__path__)
6177
if site_cuda not in cuda_paths:
6278
cuda.__path__ = cuda_paths + [site_cuda]
79+
print(f"[diag] cuda.__path__ (after): {cuda.__path__}", flush=True)
6380
import cuda.pathfinder
6481

6582
return cuda.pathfinder.get_cuda_path_or_home

cuda_core/build_hooks.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,27 @@ def _import_get_cuda_path_or_home():
5151
) from None
5252
import cuda
5353

54-
site_cuda = str(dist.locate_file(Path("cuda")))
54+
locate_result = str(dist.locate_file(Path("cuda")))
55+
print(f"[diag] dist._path: {dist._path}", flush=True)
56+
print(f"[diag] dist._path.parent: {dist._path.parent}", flush=True)
57+
print(f"[diag] locate_file('cuda'): {locate_result}", flush=True)
58+
print(f"[diag] locate_file exists: {os.path.isdir(locate_result)}", flush=True)
59+
print(
60+
f"[diag] locate_file/pathfinder exists: {os.path.isdir(os.path.join(locate_result, 'pathfinder'))}",
61+
flush=True,
62+
)
63+
print(f"[diag] cuda.__path__ (before): {cuda.__path__}", flush=True)
64+
print("[diag] sys.path:", flush=True)
65+
for p in sys.path:
66+
sp_cuda = os.path.join(p, "cuda")
67+
has_pf = os.path.isdir(os.path.join(sp_cuda, "pathfinder"))
68+
print(f"[diag] {p} -> cuda/pathfinder exists: {has_pf}", flush=True)
69+
70+
site_cuda = locate_result
5571
cuda_paths = list(cuda.__path__)
5672
if site_cuda not in cuda_paths:
5773
cuda.__path__ = cuda_paths + [site_cuda]
74+
print(f"[diag] cuda.__path__ (after): {cuda.__path__}", flush=True)
5875
import cuda.pathfinder
5976

6077
return cuda.pathfinder.get_cuda_path_or_home

0 commit comments

Comments
 (0)