Skip to content

Use pathlib in cuda.core build hooks, tests and examples (part 5 of #2410) - #2500

Open
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:pathlib/cuda-core-hooks
Open

Use pathlib in cuda.core build hooks, tests and examples (part 5 of #2410)#2500
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:pathlib/cuda-core-hooks

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown

Part 5 of #2410.

Replaces os.path with pathlib.Path in cuda_core/build_hooks.py, tests/helpers/__init__.py, the example test driver, and the two examples that assemble CUDA include paths.

ProgramOptions.include_path is typed str | list[str] | tuple[str], so the values handed to it stay str; only the path construction moves to pathlib. Same for the Extension arguments.

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 against Path("cuda", "core") and yields POSIX-style module names on every platform — which is what the old mod.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, Extension names, source tuples and arch-specific sources across all 45 modules.

glob.glob is left as-is throughout; only the pattern construction moved. os.path.isdirPath.is_dir() was checked per call rather than bulk-replaced — each one guards a "does this include/lib dir exist" decision where both spellings return False for a broken symlink or a permission error.

Verified with cuda_core/tests/test_build_hooks.py on Linux CI: 14 passed, unchanged from the baseline. The test modules and examples need a GPU or a built cuda.bindings, so those changes are by inspection plus ruff and py_compile; they are strictly mechanical.

NOTE: developed with the assistance of an AI coding agent. I reviewed and verified the change before submitting.

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.
@copy-pr-bot

copy-pr-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant