Skip to content

add sys_path to Interpreter struct#3500

Merged
konstin merged 2 commits intoastral-sh:mainfrom
ChannyClaus:syspath
May 10, 2024
Merged

add sys_path to Interpreter struct#3500
konstin merged 2 commits intoastral-sh:mainfrom
ChannyClaus:syspath

Conversation

@ChannyClaus
Copy link
Contributor

@ChannyClaus ChannyClaus commented May 10, 2024

Summary

likely necessary to resolve #2500

made this a separate PR in an attempt to make the changes as small as possible; let me know if it's preferred to keep them as a single PR.

Test Plan

  • edited the test in interpreter.rs
  • tested manually via println!
$ cargo run --quiet pip show test
["/Users/chankang/Library/Caches/uv/.tmpKzNEPN", "/Users/chankang/.pyenv/versions/3.12.2/lib/python312.zip", "/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12", "/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12/lib-dynload", "/Users/chankang/repos/uv/.venv/lib/python3.12/site-packages"]
warning: Package(s) not found for: test
chankang@chans-Air ~/repos/uv -  (syspath)
$ git diff
diff --git a/crates/uv-interpreter/src/environment.rs b/crates/uv-interpreter/src/environment.rs
index 33b785ce..8ebf0864 100644
--- a/crates/uv-interpreter/src/environment.rs
+++ b/crates/uv-interpreter/src/environment.rs
@@ -106,6 +106,7 @@ impl PythonEnvironment {
     /// Some distributions also create symbolic links from `purelib` to `platlib`; in such cases, we
     /// still deduplicate the entries, returning a single path.
     pub fn site_packages(&self) -> impl Iterator<Item = &Path> {
+        println!("{:?}", self.interpreter.sys_path());
         if let Some(target) = self.interpreter.target() {
             Either::Left(std::iter::once(target.root()))
         } else {
chankang@chans-Air ~/repos/uv -  (syspath)
$ python -c "import sys; print(sys.path)"
['', '/Users/chankang/.pyenv/versions/3.12.2/lib/python312.zip', '/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12', '/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12/lib-dynload', '/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12/site-packages']
chankang@chans-Air ~/repos/uv -  (syspath)

@ChannyClaus ChannyClaus marked this pull request as draft May 10, 2024 03:24
@ChannyClaus ChannyClaus marked this pull request as ready for review May 10, 2024 03:44
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, small PR size is great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv pip list does not read all system packages in sys.path and ignores system-site-packages

2 participants