From 12e63eb1edd626af3c1ae69d6d1c9322a560b079 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 2 Apr 2025 14:24:58 -0500 Subject: [PATCH] Report the queried executable path in `uv python list` (#12628) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Screenshot 2025-04-02 at 11 05 18 AM Closes #9979 --- crates/uv-python/src/interpreter.rs | 7 +++++++ crates/uv/src/commands/python/list.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index 2c4cb653b..4e4132b0d 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -54,6 +54,7 @@ pub struct Interpreter { prefix: Option, 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 { &self.sys_path diff --git a/crates/uv/src/commands/python/list.rs b/crates/uv/src/commands/python/list.rs index d71850aca..3e604ee8d 100644 --- a/crates/uv/src/commands/python/list.rs +++ b/crates/uv/src/commands/python/list.rs @@ -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()), )); } }