Skip to content

Commit

Permalink
add support for detecting $VIRTUAL_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
pantheraleo-7 committed Dec 15, 2024
1 parent 1abe5ce commit e4507ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/pet-global-virtualenvs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn get_global_virtualenv_dirs(
}

pub fn list_global_virtual_envs_paths(
virtual_env_env_var: Option<String>,
work_on_home_env_var: Option<String>,
xdg_data_home: Option<String>,
user_home: Option<PathBuf>,
Expand All @@ -73,6 +74,13 @@ pub fn list_global_virtual_envs_paths(
}
}

if let Some(virtual_env) = virtual_env_env_var {
let virtual_env = norm_case(expand_path(PathBuf::from(virtual_env)));
if virtual_env.exists() {
python_envs.push(virtual_env);
}
}

python_envs.sort();
python_envs.dedup();

Expand Down
1 change: 1 addition & 0 deletions crates/pet/src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub fn find_and_report_envs(

let search_paths: Vec<PathBuf> = [
list_global_virtual_envs_paths(
environment.get_env_var("VIRTUAL_ENV".into()),
environment.get_env_var("WORKON_HOME".into()),
environment.get_env_var("XDG_DATA_HOME".into()),
environment.get_user_home(),
Expand Down

0 comments on commit e4507ba

Please sign in to comment.