Skip to content

Commit 1b4f1a2

Browse files
committed
ci: add pkgutil.extend_path fallback to namespace diagnostic
If `import cuda.pathfinder` fails, try `pkgutil.extend_path` to merge the cuda namespace across sys.path entries and retry. This tests whether extend_path is a viable fix for the backend-path namespace conflict. Made-with: Cursor
1 parent 30622e3 commit 1b4f1a2

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

cuda_bindings/build_hooks.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ def _diagnose_namespace_packages():
6565
print(f"cuda.pathfinder.__file__: {cuda.pathfinder.__file__}")
6666
print(f"cuda.pathfinder.__version__: {cuda.pathfinder.__version__}")
6767
except Exception as e:
68-
print(f"import cuda.pathfinder failed: {e}")
68+
print(f"import cuda.pathfinder failed (before extend_path): {e}")
69+
try:
70+
import pkgutil
71+
72+
cuda.__path__ = pkgutil.extend_path(cuda.__path__, cuda.__name__)
73+
print(f"cuda.__path__ (after extend_path): {cuda.__path__}")
74+
import cuda.pathfinder
75+
76+
print(f"cuda.pathfinder.__file__: {cuda.pathfinder.__file__}")
77+
print(f"cuda.pathfinder.__version__: {cuda.pathfinder.__version__}")
78+
except Exception as e2:
79+
print(f"import cuda.pathfinder failed (after extend_path): {e2}")
6980
print("--- end namespace diagnostic ---")
7081

7182

cuda_core/build_hooks.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,18 @@ def _diagnose_namespace_packages():
6060
print(f"cuda.pathfinder.__file__: {cuda.pathfinder.__file__}")
6161
print(f"cuda.pathfinder.__version__: {cuda.pathfinder.__version__}")
6262
except Exception as e:
63-
print(f"import cuda.pathfinder failed: {e}")
63+
print(f"import cuda.pathfinder failed (before extend_path): {e}")
64+
try:
65+
import pkgutil
66+
67+
cuda.__path__ = pkgutil.extend_path(cuda.__path__, cuda.__name__)
68+
print(f"cuda.__path__ (after extend_path): {cuda.__path__}")
69+
import cuda.pathfinder
70+
71+
print(f"cuda.pathfinder.__file__: {cuda.pathfinder.__file__}")
72+
print(f"cuda.pathfinder.__version__: {cuda.pathfinder.__version__}")
73+
except Exception as e2:
74+
print(f"import cuda.pathfinder failed (after extend_path): {e2}")
6475
print("--- end namespace diagnostic ---")
6576

6677

0 commit comments

Comments
 (0)