You are working on cuda_pathfinder, a Python sub-package of the
cuda-python monorepo. It finds and
loads NVIDIA dynamic libraries (CTK, third-party, and driver) across Linux and
Windows.
The workspace root is cuda_pathfinder/ inside the monorepo. Use the
working_directory parameter on the Shell tool when you need the monorepo root
(one level up).
- Python: all source is pure Python (no Cython in this sub-package).
- Testing:
pytestwithpytest-mock(mockerfixture). Usespawned_process_runnerfor real-loading tests that need process isolation (dynamic linker state leaks across tests otherwise). Use theinfo_summary_appendfixture to emitINFOlines visible in CI/QA logs. - STRICTNESS env var:
CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESScontrols whether missing libs are tolerated (see_what_works, default) or fatal (all_must_work). - Formatting/linting: rely on pre-commit (runs automatically on commit). Do not run formatters manually.
- Imports: use
from cuda.pathfinder._dynamic_libs...for internal imports in tests; public API isfrom cuda.pathfinder import load_nvidia_dynamic_lib.
- Real tests over mocks: mocks are fine for hard-to-reach branches (e.g.
24-bit Python), but every loading path must also have a real-loading test that
runs in a spawned child process. Track results with
INFOlines so CI logs show what actually loaded. - No real lib names in negative tests: when parametrizing unsupported /
invalid libnames, use obviously fake names (
"bogus","not_a_real_lib") to avoid confusion when searching the codebase. functools.cacheawareness:load_nvidia_dynamic_libis cached. Tests that patch internals it depends on must callload_nvidia_dynamic_lib.cache_clear()first, or use a child process for isolation.
cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py-- main entry point and dispatch logic (CTK vs driver).cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py-- canonical registry of sonames, DLLs, site-packages paths, and dependencies.cuda/pathfinder/_dynamic_libs/find_nvidia_dynamic_lib.py-- CTK search cascade (site-packages, conda, CUDA_HOME).tests/child_load_nvidia_dynamic_lib_helper.py-- lightweight helper imported by spawned child processes (avoids re-importing the full test module).
Request: Fix all 8 findings from the external code review.
Actions (in worktree cuda_pathfinder_refactor):
search_steps.py: Restoredos.path.normpath(dirname)in_find_lib_dir_using_anchor(regression from pre-refactor fix). AddedNoReturnannotation toraise_not_found.search_platform.py: Guardedos.listdir(lib_dir)inWindowsSearchPlatform.find_in_lib_dirwithos.path.isdircheck to prevent crash on missing directory.test_descriptor_catalog.py: Rewrote tautological tests as structural invariant tests (uniqueness, valid names, strategy values, dep graph, soname/dll format, driver lib constraints). 237 new parametrized cases.platform_loader.py: EliminatedWindowsLoader/LinuxLoaderboilerplate classes — assign the platform module directly asLOADER. Removed staletype: ignore.descriptor_catalog.py: Trimmed default-valued fields from all entries, added# ---section comments (CTK / third-party / driver).load_nvidia_dynamic_lib.py: Fixed import layout —TYPE_CHECKINGblock now properly separated after unconditional imports.
All 742 tests pass, all pre-commit hooks green.