diff --git a/cuda_bindings/build_hooks.py b/cuda_bindings/build_hooks.py index a50133f9777..99ad5c66268 100644 --- a/cuda_bindings/build_hooks.py +++ b/cuda_bindings/build_hooks.py @@ -16,6 +16,7 @@ import sys import sysconfig import tempfile +from pathlib import Path from warnings import warn from setuptools import build_meta as _build_meta @@ -50,9 +51,9 @@ def _import_get_cuda_path_or_home(): cuda = None for p in sys.path: - sp_cuda = os.path.join(p, "cuda") - if os.path.isdir(os.path.join(sp_cuda, "pathfinder")): - cuda.__path__ = list(cuda.__path__) + [sp_cuda] + sp_cuda = Path(p) / "cuda" + if (sp_cuda / "pathfinder").is_dir(): + cuda.__path__ = list(cuda.__path__) + [str(sp_cuda)] break else: raise ModuleNotFoundError( @@ -61,6 +62,11 @@ def _import_get_cuda_path_or_home(): ) import cuda.pathfinder + pathfinder_dir = Path(cuda.pathfinder.__file__).parent + print( + f"Using cuda-pathfinder {cuda.pathfinder.__version__} from {pathfinder_dir}", + file=sys.stderr, + ) return cuda.pathfinder.get_cuda_path_or_home diff --git a/cuda_core/build_hooks.py b/cuda_core/build_hooks.py index 4aec4981c53..05cc9267726 100644 --- a/cuda_core/build_hooks.py +++ b/cuda_core/build_hooks.py @@ -46,9 +46,9 @@ def _import_get_cuda_path_or_home(): cuda = None for p in sys.path: - sp_cuda = os.path.join(p, "cuda") - if os.path.isdir(os.path.join(sp_cuda, "pathfinder")): - cuda.__path__ = list(cuda.__path__) + [sp_cuda] + sp_cuda = Path(p) / "cuda" + if (sp_cuda / "pathfinder").is_dir(): + cuda.__path__ = list(cuda.__path__) + [str(sp_cuda)] break else: raise ModuleNotFoundError( @@ -57,6 +57,11 @@ def _import_get_cuda_path_or_home(): ) import cuda.pathfinder + pathfinder_dir = Path(cuda.pathfinder.__file__).parent + print( + f"Using cuda-pathfinder {cuda.pathfinder.__version__} from {pathfinder_dir}", + file=sys.stderr, + ) return cuda.pathfinder.get_cuda_path_or_home @@ -136,6 +141,7 @@ def _build_cuda_core(debug=False): import cuda.bindings bindings_path = Path(cuda.bindings.__file__).parent # .../cuda/bindings/ + print(f"Using cuda-bindings {cuda.bindings.__version__} from {bindings_path}", file=sys.stderr) cuda_package_dir = bindings_path.parent.parent # .../cuda_bindings/ (contains cuda/) if str(cuda_package_dir) not in sys.path: sys.path.insert(0, str(cuda_package_dir))