-
Notifications
You must be signed in to change notification settings - Fork 604
fix(build): Handle namespace packages for PyPI CUDA detection #2580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,7 +239,13 @@ def get_cuda_include_dirs() -> Tuple[str, str]: | |
| except ModuleNotFoundError as e: | ||
| raise RuntimeError("CUDA not found.") | ||
|
|
||
| cuda_root = Path(nvidia.__file__).parent | ||
| # Handle namespace packages (PEP 420) which don't have __file__ | ||
| # The nvidia package from PyPI CUDA packages is a namespace package | ||
| if hasattr(nvidia, "__path__") and nvidia.__path__: | ||
| cuda_root = Path(list(nvidia.__path__)[0]) | ||
| else: | ||
| raise RuntimeError("Could not locate nvidia package directory.") | ||
|
Comment on lines
+242
to
+247
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fix correctly handles namespace packages here, but
Consider applying the same fix pattern ( |
||
|
|
||
| return [ | ||
| subdir / "include" | ||
| for subdir in cuda_root.iterdir() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
list()conversion -nvidia.__path__is already indexable, can usenvidia.__path__[0]directly