Skip to content

[BUG][pathfinder] Incorrect site-packages search order for venv created with --system-site-packages #1716

@rwgk

Description

@rwgk

This summarizes a group chat discussion and additionally documents Cursor-based verification:


Problem

When cuda.pathfinder.load_nvidia_dynamic_lib searches for NVIDIA dynamic libraries in site-packages, it currently searches in the following order unconditionally:

  1. User site-packages (site.getusersitepackages())
  2. Site packages from site.getsitepackages() (which includes both virtual environment and system site-packages)

This ordering causes issues in a venv created with --system-site-packages: according to PEP 405 the correct search order should be (verified as explained below):

  1. Virtual environment site-packages
  2. User site-packages
  3. System site-packages

Cursor-based verification

PEP 405 (Virtual Environments):

  • States that in a venv with --system-site-packages, system site directories are added after virtual environment site directories.
  • Notes that PEP 370 user-level site-packages are considered part of system site-packages for venv purposes.

PEP 370 (User Site-Packages):

  • States that user-site-packages are added before system site-packages (outside venv context).

Actual Python Behavior (verified by test):
In a venv with --system-site-packages, Python's sys.path order is:

  1. Virtual environment site-packages
  2. User site-packages
  3. System site-packages

This confirms that the correct search order described above matches both PEP 405, PEP 370, and Python's actual behavior.

References

Metadata

Metadata

Assignees

Labels

cuda.pathfinderEverything related to the cuda.pathfinder module

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions