Skip to content
Merged
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
17 changes: 15 additions & 2 deletions crates/pet-virtualenv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use std::path::Path;
use std::path::{Path, PathBuf};

use pet_core::{
env::PythonEnv,
Expand Down Expand Up @@ -40,6 +40,19 @@ pub fn is_virtualenv_dir(path: &Path) -> bool {
path = path.join("bin");
}
}

// Never consider global locations to be virtualenvs
// in case there is a false positive match from checks below.
if [
PathBuf::from(r"/bin"),
PathBuf::from(r"/usr/bin"),
PathBuf::from(r"/usr/local/bin"),
]
.contains(&path)
{
return false;
}

// Check if there are any activate.* files in the same directory as the interpreter.
//
// env
Expand All @@ -62,7 +75,7 @@ pub fn is_virtualenv_dir(path: &Path) -> bool {
.unwrap_or_default()
.to_str()
.unwrap_or_default()
.starts_with("activate")
.starts_with("activate.")
{
return true;
}
Expand Down
Loading