Skip to content

Commit e4507ba

Browse files
committed
add support for detecting $VIRTUAL_ENV
1 parent 1abe5ce commit e4507ba

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

crates/pet-global-virtualenvs/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn get_global_virtualenv_dirs(
5656
}
5757

5858
pub fn list_global_virtual_envs_paths(
59+
virtual_env_env_var: Option<String>,
5960
work_on_home_env_var: Option<String>,
6061
xdg_data_home: Option<String>,
6162
user_home: Option<PathBuf>,
@@ -73,6 +74,13 @@ pub fn list_global_virtual_envs_paths(
7374
}
7475
}
7576

77+
if let Some(virtual_env) = virtual_env_env_var {
78+
let virtual_env = norm_case(expand_path(PathBuf::from(virtual_env)));
79+
if virtual_env.exists() {
80+
python_envs.push(virtual_env);
81+
}
82+
}
83+
7684
python_envs.sort();
7785
python_envs.dedup();
7886

crates/pet/src/find.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ pub fn find_and_report_envs(
160160

161161
let search_paths: Vec<PathBuf> = [
162162
list_global_virtual_envs_paths(
163+
environment.get_env_var("VIRTUAL_ENV".into()),
163164
environment.get_env_var("WORKON_HOME".into()),
164165
environment.get_env_var("XDG_DATA_HOME".into()),
165166
environment.get_user_home(),

0 commit comments

Comments
 (0)