Report the queried executable path in uv python list (#12628)

In an attempt to avoid reporting shims as their resolved
`sys.executable` path, we report the queried executable path instead.
This seems more correct for this command, broadly? Interestingly, it
changes the reported paths for Homebrew Python

<img width="1430" alt="Screenshot 2025-04-02 at 11 05 18 AM"
src="https://github.com/user-attachments/assets/0e1600e8-fb07-40c7-a6d6-56eaeb4b9293"
/>

Closes #9979
This commit is contained in:
Zanie Blue 2025-04-02 14:24:58 -05:00 committed by GitHub
parent 72f34157c6
commit 12e63eb1ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -54,6 +54,7 @@ pub struct Interpreter {
prefix: Option<Prefix>,
pointer_size: PointerSize,
gil_disabled: bool,
real_executable: PathBuf,
}
impl Interpreter {
@ -86,6 +87,7 @@ impl Interpreter {
tags: OnceLock::new(),
target: None,
prefix: None,
real_executable: executable.as_ref().to_path_buf(),
})
}
@ -393,6 +395,11 @@ impl Interpreter {
&self.sys_executable
}
/// Return the "real" queried executable path for this Python interpreter.
pub fn real_executable(&self) -> &Path {
&self.real_executable
}
/// Return the `sys.path` for this Python interpreter.
pub fn sys_path(&self) -> &Vec<PathBuf> {
&self.sys_path

View file

@ -148,7 +148,7 @@ pub(crate) async fn list(
output.insert((
installation.key(),
kind,
Either::Left(installation.interpreter().sys_executable().to_path_buf()),
Either::Left(installation.interpreter().real_executable().to_path_buf()),
));
}
}