Skip to content

Commit 078c70b

Browse files
authored
Merge branch 'main' into deduplicate-global-paths
2 parents 695bbf7 + 871e179 commit 078c70b

6 files changed

Lines changed: 55 additions & 95 deletions

File tree

Cargo.lock

Lines changed: 33 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pet-virtualenv/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
use std::path::Path;
4+
use std::path::{Path, PathBuf};
55

66
use pet_core::{
77
env::PythonEnv,
@@ -40,6 +40,19 @@ pub fn is_virtualenv_dir(path: &Path) -> bool {
4040
path = path.join("bin");
4141
}
4242
}
43+
44+
// Never consider global locations to be virtualenvs
45+
// in case there is a false positive match from checks below.
46+
if [
47+
PathBuf::from(r"/bin"),
48+
PathBuf::from(r"/usr/bin"),
49+
PathBuf::from(r"/usr/local/bin"),
50+
]
51+
.contains(&path)
52+
{
53+
return false;
54+
}
55+
4356
// Check if there are any activate.* files in the same directory as the interpreter.
4457
//
4558
// env
@@ -62,7 +75,7 @@ pub fn is_virtualenv_dir(path: &Path) -> bool {
6275
.unwrap_or_default()
6376
.to_str()
6477
.unwrap_or_default()
65-
.starts_with("activate")
78+
.starts_with("activate.")
6679
{
6780
return true;
6881
}

crates/pet-virtualenvwrapper/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ impl Locator for VirtualEnvWrapper {
4949
},
5050
};
5151
let mut symlinks = vec![];
52+
let mut name = None;
5253
if let Some(ref prefix) = env.prefix {
5354
symlinks.append(&mut find_executables(prefix));
55+
name = prefix.file_name().and_then(|f| f.to_str());
5456
}
5557

5658
Some(
5759
PythonEnvironmentBuilder::new(Some(PythonEnvironmentKind::VirtualEnvWrapper))
60+
.name(name.map(String::from))
5861
.executable(Some(env.executable.clone()))
5962
.version(version)
6063
.prefix(env.prefix.clone())

crates/pet-windows-registry/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[target.'cfg(windows)'.dependencies]
7-
winreg = "0.52.0"
7+
winreg = "0.55.0"
88

99
[target.'cfg(target_os = "windows")'.dependencies]
1010
msvc_spectre_libs = { version = "0.1.1", features = ["error"] }
@@ -18,4 +18,4 @@ pet-fs = { path = "../pet-fs" }
1818
pet-conda = { path = "../pet-conda" }
1919
log = "0.4.21"
2020
lazy_static = "1.4.0"
21-
regex = "1.10.4"
21+
regex = "1.10.4"

crates/pet-windows-store/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[target.'cfg(windows)'.dependencies]
7-
winreg = "0.52.0"
7+
winreg = "0.55.0"
88

99
[target.'cfg(target_os = "windows")'.dependencies]
1010
msvc_spectre_libs = { version = "0.1.1", features = ["error"] }

crates/pet/tests/ci_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ fn check_if_virtualenvwrapper_exists() {
161161
|env| env.kind == Some(PythonEnvironmentKind::VirtualEnvWrapper)
162162
&& env.executable.is_some()
163163
&& env.prefix.is_some()
164+
&& env.name == Some("venv_wrapper_env1".to_string())
164165
&& env
165166
.executable
166167
.clone()

0 commit comments

Comments
 (0)