Skip to content

Commit

Permalink
Expand the environments directories (#162)
Browse files Browse the repository at this point in the history
Fixes #161
  • Loading branch information
DonJayamanne authored Oct 3, 2024
1 parent 763050e commit 451025f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 16 additions & 1 deletion crates/pet/src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,28 @@ pub fn find_and_report_envs(
s.spawn(|| {
let start = std::time::Instant::now();
if search_global {
let mut possible_environments = vec![];

// These are directories that contain environments, hence enumerate these directories.
for directory in environment_directories {
if let Ok(reader) = fs::read_dir(directory) {
possible_environments.append(
&mut reader
.filter_map(Result::ok)
.filter(|d| d.file_type().is_ok_and(|f| f.is_dir()))
.map(|p| p.path())
.collect(),
);
}
}

let search_paths: Vec<PathBuf> = [
list_global_virtual_envs_paths(
environment.get_env_var("WORKON_HOME".into()),
environment.get_env_var("XDG_DATA_HOME".into()),
environment.get_user_home(),
),
environment_directories,
possible_environments,
]
.concat();
let global_env_search_paths: Vec<PathBuf> =
Expand Down
5 changes: 4 additions & 1 deletion crates/pet/tests/ci_homebrew_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn verify_python_in_homebrew_contaner() {
let python3_12 = PythonEnvironment {
kind: Some(PythonEnvironmentKind::Homebrew),
executable: Some(PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3")),
version: Some("3.12.6".to_string()), // This can change on CI, so we don't check it
version: Some("3.12.7".to_string()), // This can change on CI, so we don't check it
symlinks: Some(vec![
PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3"),
PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3.12"),
Expand Down Expand Up @@ -103,6 +103,9 @@ fn verify_python_in_homebrew_contaner() {
.filter(|p| {
!p.to_string_lossy()
.contains(&env.version.clone().unwrap_or_default())
&& !p
.to_string_lossy()
.contains(&python_env.version.clone().unwrap_or_default())
})
.collect::<Vec<PathBuf>>();
assert_eq!(
Expand Down

0 comments on commit 451025f

Please sign in to comment.