Skip to content

Commit 2aa3290

Browse files
authored
Fallback to finding conda install dir if not found (#159)
For #142 For #155
1 parent e76a8db commit 2aa3290

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

crates/pet-conda/src/environments.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
package::{CondaPackageInfo, Package},
77
utils::{is_conda_env, is_conda_install},
88
};
9-
use log::warn;
9+
use log::{trace, warn};
1010
use pet_core::{
1111
arch::Architecture,
1212
manager::EnvManager,
@@ -76,20 +76,30 @@ pub fn get_conda_environment_info(
7676
return None;
7777
}
7878
// If we know the conda install folder, then we can use it.
79-
let mut conda_install_folder = match manager {
80-
Some(manager) => manager.conda_dir.clone(),
81-
None => get_conda_installation_used_to_create_conda_env(env_path),
82-
};
79+
let mut conda_install_folder = manager
80+
.clone()
81+
.and_then(|m| m.conda_dir)
82+
.or_else(|| get_conda_installation_used_to_create_conda_env(env_path));
83+
8384
if let Some(conda_dir) = &conda_install_folder {
84-
if !conda_dir.exists() {
85+
if conda_dir.exists() {
86+
trace!(
87+
"Conda install folder {}, found, & will not be used for the Conda Env: {}",
88+
env_path.display(),
89+
conda_dir.display()
90+
);
91+
} else {
8592
warn!(
8693
"Conda install folder {}, does not exist, hence will not be used for the Conda Env: {}",
8794
env_path.display(),
8895
conda_dir.display()
8996
);
9097
conda_install_folder = None;
9198
}
99+
} else {
100+
trace!("Conda install folder not found for {}", env_path.display());
92101
}
102+
93103
if let Some(python_binary) = find_executable(env_path) {
94104
if let Some(package_info) = CondaPackageInfo::from(env_path, &Package::Python) {
95105
Some(CondaEnvironment {

0 commit comments

Comments
 (0)