Use pathlib in cuda.core build hooks, tests and examples (part 5 of #2410) - #2500
Open
LeSingh1 wants to merge 1 commit into
Open
Use pathlib in cuda.core build hooks, tests and examples (part 5 of #2410)#2500LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
Part of NVIDIA#2410. Replaces os.path with pathlib.Path in cuda_core/build_hooks.py, tests/helpers, the example test driver and the two examples that assemble CUDA include paths. ProgramOptions.include_path is typed str, so the values handed to it stay str; only the path construction moves to pathlib.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 5 of #2410.
Replaces
os.pathwithpathlib.Pathincuda_core/build_hooks.py,tests/helpers/__init__.py, the example test driver, and the two examples that assemble CUDA include paths.ProgramOptions.include_pathis typedstr | list[str] | tuple[str], so the values handed to it staystr; only the path construction moves to pathlib. Same for theExtensionarguments.The one non-mechanical change is extension discovery, which previously sliced glob result strings against an
os.path.sep-built prefix. It now relative-paths againstPath("cuda", "core")and yields POSIX-style module names on every platform — which is what the oldmod.replace(os.path.sep, "/")normalization already did. I checked that by re-implementing the old and new logic side by side and diffing them against the real source tree on Linux: identical module names,Extensionnames, source tuples and arch-specific sources across all 45 modules.glob.globis left as-is throughout; only the pattern construction moved.os.path.isdir→Path.is_dir()was checked per call rather than bulk-replaced — each one guards a "does this include/lib dir exist" decision where both spellings returnFalsefor a broken symlink or a permission error.Verified with
cuda_core/tests/test_build_hooks.pyon Linux CI: 14 passed, unchanged from the baseline. The test modules and examples need a GPU or a builtcuda.bindings, so those changes are by inspection plusruffandpy_compile; they are strictly mechanical.NOTE: developed with the assistance of an AI coding agent. I reviewed and verified the change before submitting.