Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions crates/uv-python/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,25 +1274,29 @@ pub fn find_all_python_installations(
source: PythonSource::ProvidedPath,
interpreter,
}]),
Err(InterpreterError::NotFound(_) | InterpreterError::BrokenLink(_)) => Ok(vec![]),
Err(err) => Err(Error::Query(
Box::new(err),
path.clone(),
PythonSource::ProvidedPath,
)),
Err(err) => {
let err = Error::Query(Box::new(err), path.clone(), PythonSource::ProvidedPath);
if err.is_critical() {
Err(err)
} else {
Ok(vec![])
}
}
}
}
PythonRequest::Directory(path) => {
preference.check_allows_request_source(request, PythonSource::ProvidedPath)?;
debug!("Checking for Python interpreter in {request}");
match python_installation_from_directory(path, cache) {
Ok(installation) => Ok(vec![installation]),
Err(InterpreterError::NotFound(_) | InterpreterError::BrokenLink(_)) => Ok(vec![]),
Err(err) => Err(Error::Query(
Box::new(err),
path.clone(),
PythonSource::ProvidedPath,
)),
Err(err) => {
let err = Error::Query(Box::new(err), path.clone(), PythonSource::ProvidedPath);
if err.is_critical() {
Err(err)
} else {
Ok(vec![])
}
}
}
}
PythonRequest::ExecutableName(name) => {
Expand Down
45 changes: 45 additions & 0 deletions crates/uv/tests/python/python_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,51 @@ fn python_list() {
");
}

#[cfg(unix)]
#[test]
fn python_list_ignores_noncritical_explicit_path_errors() -> Result<()> {
use std::os::unix::fs::PermissionsExt;

let context = uv_test::test_context_with_versions!(&[]);
let contents = r"#!/bin/sh
echo 'error: intentionally broken python executable' >&2
exit 1";

let python = context.temp_dir.join("python");
fs_err::write(&python, contents)?;
let mut permissions = fs_err::metadata(&python)?.permissions();
permissions.set_mode(0o755);
fs_err::set_permissions(&python, permissions)?;

uv_snapshot!(context.filters(), context.python_list()
.arg(&python)
.arg("--only-installed"), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
");

let environment = context.temp_dir.join("environment");
let environment_bin = environment.join("bin");
let environment_python = environment_bin.join("python");
fs_err::create_dir_all(&environment_bin)?;
fs_err::copy(&python, &environment_python)?;

uv_snapshot!(context.filters(), context.python_list()
.arg(&environment)
.arg("--only-installed"), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
");

Ok(())
}

#[test]
fn python_list_pin() {
let context = uv_test::test_context_with_versions!(&["3.11", "3.12"])
Expand Down
Loading