Skip to content

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

Closed

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

Activity

  1. self-assigned this
    on Mar 4, 2026
  2. added
    cuda.pathfinderEverything related to the cuda.pathfinder module
    on Mar 4, 2026
  3. added theissue type on Mar 4, 2026
  4. added a commit that references this issue on Mar 4, 2026
    617f8ea
  5. added a commit that references this issue on Mar 4, 2026
    244738a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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