Use pathlib in cuda.pathfinder._static_libs (part 2 of #2410) - #2493
Open
LeSingh1 wants to merge 2 commits into
Open
Use pathlib in cuda.pathfinder._static_libs (part 2 of #2410)#2493LeSingh1 wants to merge 2 commits into
LeSingh1 wants to merge 2 commits into
Conversation
Part 2 of the series proposed in NVIDIA#2410, following the same conversion style as part 1 (NVIDIA#2489). Path construction, joining, and filesystem predicates in find_static_lib.py and find_bitcode_lib.py now go through pathlib.Path instead of os.path string manipulation. Both modules keep importing os solely for os.environ.get("CONDA_PREFIX"). Compatibility is preserved: every entry point still accepts str, and every function that documents or returns str still returns str. Path is used strictly as the internal representation and converted back with str() at each return, so LocatedStaticLib.abs_path, LocatedBitcodeLib .abs_path, find_static_lib() and find_bitcode_lib() are unchanged in both type and value. No signature changes. Signed-off-by: LeSingh1 <sshaurya914@gmail.com>
Follow-up to the review feedback on NVIDIA#2489: the str-compatibility constraint applies only to the public API. The try_* methods and _no_such_file_in_dir now work in Path throughout. str() is applied once, where abs_path is stored on the public LocatedStaticLib and LocatedBitcodeLib. The relative-path constants go from os.path.join(...) to forward-slash literals, matching how site_packages_dirs is already written in the same dicts; Path normalizes the separator on Windows. One behavior change: a CUDA_PATH or CONDA_PREFIX containing redundant separators ("//", "/.") now produces a normalized abs_path, because Path collapses them. Differential fuzzing against the pre-revision code (16k lookups over randomized trees, comparing located paths and full error text) shows no other difference, and none at all when those variables are free of redundant separators. Signed-off-by: LeSingh1 <sshaurya914@gmail.com>
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.
Follow-up to the review on #2489: the str-compatibility constraint applies only to the public API, so the finder internals now pass and return
Path.str()is applied once, whereabs_pathis stored onLocatedStaticLib/LocatedBitcodeLib.The rel-path constants are now forward-slash literals, matching
site_packages_dirsin the same dicts.One behaviour change: a
CUDA_PATHorCONDA_PREFIXcontaining redundant separators now gives a normalizedabs_path, becausePathcollapses them.Verified on Linux CI: full pytest output byte-identical to the base commit apart from elapsed time (1276 passed, 4 skipped, 0 errors). Differential fuzzing against the previous revision — 16k lookups over randomized trees, comparing located paths and error text — shows no other difference.
Part 2 of #2410.