mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 10:33:49 +00:00
Omit interpreter path during uv venv
with managed Python (#5311)
e.g. ``` ❯ cargo run -q -- venv --preview Using Python 3.12.1 Creating virtualenv at: .venv Activate with: source .venv/bin/activate ``` instead of ``` ❯ cargo run -q -- venv --preview Using Python 3.12.1 interpreter at: /Users/zb/Library/Application Support/uv/python/cpython-3.12.1-macos-aarch64-none/bin/python3 Creating virtualenv at: .venv Activate with: source .venv/bin/activate ```
This commit is contained in:
parent
3a85353707
commit
6fe9bd8a80
2 changed files with 27 additions and 10 deletions
|
@ -1244,6 +1244,12 @@ impl PythonRequest {
|
|||
}
|
||||
}
|
||||
|
||||
impl PythonSource {
|
||||
pub fn is_managed(&self) -> bool {
|
||||
matches!(self, Self::Managed)
|
||||
}
|
||||
}
|
||||
|
||||
impl PythonPreference {
|
||||
fn allows(self, source: PythonSource) -> bool {
|
||||
// If not dealing with a system interpreter source, we don't care about the preference
|
||||
|
|
|
@ -140,7 +140,7 @@ async fn venv_impl(
|
|||
}
|
||||
|
||||
// Locate the Python interpreter to use in the environment
|
||||
let interpreter = PythonInstallation::find_or_fetch(
|
||||
let python = PythonInstallation::find_or_fetch(
|
||||
interpreter_request,
|
||||
EnvironmentPreference::OnlySystem,
|
||||
python_preference,
|
||||
|
@ -150,21 +150,32 @@ async fn venv_impl(
|
|||
Some(&reporter),
|
||||
)
|
||||
.await
|
||||
.into_diagnostic()?
|
||||
.into_interpreter();
|
||||
.into_diagnostic()?;
|
||||
|
||||
let managed = python.source().is_managed();
|
||||
let interpreter = python.into_interpreter();
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Using Python {} interpreter at: {}",
|
||||
interpreter.python_version(),
|
||||
interpreter.sys_executable().user_display().cyan()
|
||||
)
|
||||
.into_diagnostic()?;
|
||||
if managed {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Using Python {}",
|
||||
interpreter.python_version().cyan()
|
||||
)
|
||||
.into_diagnostic()?;
|
||||
} else {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Using Python {} interpreter at: {}",
|
||||
interpreter.python_version(),
|
||||
interpreter.sys_executable().user_display().cyan()
|
||||
)
|
||||
.into_diagnostic()?;
|
||||
}
|
||||
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue