Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand the environments directories #162

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
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: 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
Loading