Use pathlib in cuda.bindings build hooks and tests (part 6 of #2410) - #2501
Use pathlib in cuda.bindings build hooks and tests (part 6 of #2410)#2501LeSingh1 wants to merge 1 commit into
Conversation
| examples_path = os.path.join(os.path.dirname(__file__), "..", "examples") | ||
| examples_files = glob.glob(os.path.join(examples_path, "**/*.py"), recursive=True) | ||
| examples_path = Path(__file__).parents[1] / "examples" | ||
| examples_files = glob.glob(str(examples_path / "**" / "*.py"), recursive=True) |
| path = Path("cuda", "bindings", "_internal") | ||
| if sys.platform == "linux": | ||
| src_files = glob.glob(os.path.join(path, "*_linux.pyx")) | ||
| src_files = glob.glob(str(path / "*_linux.pyx")) |
| src_files = glob.glob(str(path / "*_linux.pyx")) | ||
| elif sys.platform == "win32": | ||
| src_files = glob.glob(os.path.join(path, "*_windows.pyx")) | ||
| src_files = glob.glob(str(path / "*_windows.pyx")) |
| exts = [] | ||
| for pyx in files: | ||
| mod_name = pyx.replace(".pyx", "").replace(os.sep, ".").replace("/", ".") | ||
| mod_name = ".".join(Path(pyx).with_suffix("").parts) |
Part of NVIDIA#2410. Replaces os.path/os.sep with pathlib.Path in cuda_bindings/build_hooks.py and in the test modules that build paths to the test data, the examples directory and the reproducer cwd. Directory listings use Path.glob instead of glob.glob over a stringified pattern, so _rename_architecture_specific_files() now returns Path objects and its consumers use .name / .suffix. Values handed to setuptools' Extension and to the cuFile string parameters stay str; only the path construction moves to pathlib. _prep_extensions() keeps glob.glob because its input is a glob pattern rather than a directory.
93717cf to
5d7816e
Compare
|
Switched both spots to
I left Two things I checked rather than assumed:
With bare Not run locally: the cuda_bindings suite and a real wheel build need CUDA and a toolkit. py_compile, ruff and ruff format are clean; CI is the gate. |
Part 6 of #2410, and the last of the series.
Replaces
os.path/os.sepwithpathlib.Pathincuda_bindings/build_hooks.pyand in the test modules that build paths to test data, the examples directory, and a reproducer's cwd.Values handed to setuptools'
Extension(include_dirs,library_dirs) and to the cuFile string parameters staystr; only the path construction moves to pathlib.As in part 5,
glob.globis left alone and only the pattern construction moved, and I diffed the old and new extension-discovery logic against the real source tree on Linux — identical across all 39cuda.bindingsmodule names and basenames, and identical include/library dir lists.One cosmetic note: the
test_examples.pyparametrize IDs change from.../tests/../examples/foo.pyto.../examples/foo.py. Same file set — I greppedci/,.github/,scripts/andtoolshed/and nothing selects these tests by ID. Happy to preserve the literal..if you would rather keep the IDs stable.These files all need a GPU or a built
cuda.bindings, so the changes are verified by inspection plusruff check,ruff format --checkandpy_compilerather than by a test run;cuda_core/tests/test_build_hooks.pystill passes 14/14 on Linux CI.NOTE: developed with the assistance of an AI coding agent. I reviewed and verified the change before submitting.