Consolidate logic for checking for a virtual environment (#14214)
We were checking whether a path was an executable in a virtual environment or the base directory of a virtual environment in multiple places in the codebase. This PR consolidates this logic into one place. Closes #13947.
This commit is contained in:
@@ -993,14 +993,9 @@ impl InterpreterInfo {
|
||||
.symlink_metadata()
|
||||
.is_ok_and(|metadata| metadata.is_symlink())
|
||||
{
|
||||
let venv = executable
|
||||
.parent()
|
||||
.and_then(Path::parent)
|
||||
.map(|path| path.join("pyvenv.cfg").is_file())
|
||||
.unwrap_or(false);
|
||||
Error::BrokenSymlink(BrokenSymlink {
|
||||
path: executable.to_path_buf(),
|
||||
venv,
|
||||
venv: uv_fs::is_virtualenv_executable(executable),
|
||||
})
|
||||
} else {
|
||||
Error::NotFound(executable.to_path_buf())
|
||||
|
||||
Reference in New Issue
Block a user