diff --git a/.devcontainer/linux-x64/Dockerfile b/.devcontainer/linux-x64/Dockerfile index af35d3fa..61fd886e 100644 --- a/.devcontainer/linux-x64/Dockerfile +++ b/.devcontainer/linux-x64/Dockerfile @@ -1,4 +1,4 @@ -FROM amd64/ubuntu +FROM amd64/ubuntu:24.04 # Setup Python RUN apt-get update && \ diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 0ba26d7c..1420a20c 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -133,7 +133,7 @@ jobs: if: startsWith( matrix.os, 'ubuntu') || startsWith( matrix.os, 'macos') run: | pyenv install --list - pyenv install 3.12.5 3.8.19 + pyenv install 3.12.6 3.8.19 shell: bash # pyenv-win install list has not updated for a while diff --git a/crates/pet-conda/src/environments.rs b/crates/pet-conda/src/environments.rs index 74a025de..9a62ddfc 100644 --- a/crates/pet-conda/src/environments.rs +++ b/crates/pet-conda/src/environments.rs @@ -6,7 +6,7 @@ use crate::{ package::{CondaPackageInfo, Package}, utils::{is_conda_env, is_conda_install}, }; -use log::warn; +use log::{info, warn}; use pet_core::{ arch::Architecture, manager::EnvManager, @@ -76,10 +76,40 @@ pub fn get_conda_environment_info( return None; } // If we know the conda install folder, then we can use it. + let conda_install_folder2 = manager + .clone() + .and_then(|m| m.conda_dir) + .or_else(|| get_conda_installation_used_to_create_conda_env(env_path)); let mut conda_install_folder = match manager { Some(manager) => manager.conda_dir.clone(), None => get_conda_installation_used_to_create_conda_env(env_path), }; + match manager { + Some(manager) => { + if conda_install_folder.is_none() { + warn!( + "Given a conda Conda manager but no conda_install_folder for {:?} => {:?}", + env_path, manager + ); + } else { + info!( + "Given a conda Conda manager & found the conda_install_folder for {:?} => {:?}", + env_path, manager + ); + } + } + None => { + warn!("No conda Conda manager given for {:?}", env_path); + } + } + info!( + "Got ({:?} & {:?}) install folder for {:?} => {:?} and install folder 2 as {:?}", + conda_install_folder.is_some(), + conda_install_folder2.is_some(), + env_path, + conda_install_folder, + conda_install_folder2 + ); if let Some(conda_dir) = &conda_install_folder { if !conda_dir.exists() { warn!( diff --git a/crates/pet-conda/src/lib.rs b/crates/pet-conda/src/lib.rs index 6e035a1a..15697592 100644 --- a/crates/pet-conda/src/lib.rs +++ b/crates/pet-conda/src/lib.rs @@ -8,7 +8,7 @@ use environment_locations::{ get_environments, }; use environments::{get_conda_environment_info, CondaEnvironment}; -use log::error; +use log::{error, info}; use manager::CondaManager; use pet_core::{ env::PythonEnv, @@ -245,9 +245,14 @@ impl Locator for Conda { if let Some(env) = environments.get(path) { return Some(env.clone()); } + info!("Getting conda env info for {:?}", path); + if let Some(env) = get_conda_environment_info(path, &None) { + info!("Got conda env info for {:?} => {:?}", path, env); if let Some(conda_dir) = &env.conda_dir { + info!("Got Conda dir and now Getting conda manager for {:?}", path); if let Some(manager) = self.get_manager(conda_dir) { + info!("Got conda manager for {:?} => {:?}", path, manager); let env = env.to_python_environment( Some(conda_dir.clone()), Some(manager.to_manager()), @@ -255,6 +260,7 @@ impl Locator for Conda { environments.insert(path.clone(), env.clone()); return Some(env); } else { + error!("Did not get conda manager for {:?}", path); // We will still return the conda env even though we do not have the manager. // This might seem incorrect, however the tool is about discovering environments. // The client can activate this env either using another conda manager or using the activation scripts @@ -264,6 +270,7 @@ impl Locator for Conda { return Some(env); } } else { + error!("Did not get conda dir for {:?}", path); // We will still return the conda env even though we do not have the manager. // This might seem incorrect, however the tool is about discovering environments. // The client can activate this env either using another conda manager or using the activation scripts @@ -272,6 +279,8 @@ impl Locator for Conda { environments.insert(path.clone(), env.clone()); return Some(env); } + } else { + error!("Did not get conda env info for {:?}", path); } } None diff --git a/crates/pet-windows-registry/src/environments.rs b/crates/pet-windows-registry/src/environments.rs index c10cfc34..4a2f8c6d 100644 --- a/crates/pet-windows-registry/src/environments.rs +++ b/crates/pet-windows-registry/src/environments.rs @@ -101,6 +101,13 @@ fn get_registry_pythons_from_key_for_company( Ok(install_path_key) => { let env_path: String = install_path_key.get_value("").ok().unwrap_or_default(); + if env_path.is_empty() { + warn!( + "Install path is empty {}\\Software\\Python\\{}\\{}", + key_container, company, installed_python + ); + continue; + } let env_path = norm_case(PathBuf::from(env_path)); if is_windows_app_folder_in_program_files(&env_path) { trace!( diff --git a/crates/pet/tests/ci_homebrew_container.rs b/crates/pet/tests/ci_homebrew_container.rs index b7032623..16d454d9 100644 --- a/crates/pet/tests/ci_homebrew_container.rs +++ b/crates/pet/tests/ci_homebrew_container.rs @@ -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.5".to_string()), // This can change on CI, so we don't check it + version: Some("3.12.6".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"), @@ -61,19 +61,19 @@ fn verify_python_in_homebrew_contaner() { PathBuf::from("/home/linuxbrew/.linuxbrew/opt/python@3.12/bin/python3"), PathBuf::from("/home/linuxbrew/.linuxbrew/opt/python@3.12/bin/python3.12"), // On CI the Python version can change with minor updates, so we don't check the full version. - // PathBuf::from("/home/linuxbrew/.linuxbrew/Cellar/python@3.12/3.12.5/bin/python3.12"), + // PathBuf::from("/home/linuxbrew/.linuxbrew/Cellar/python@3.12/3.12.6/bin/python3.12"), ]), ..Default::default() }; let python3_11 = PythonEnvironment { kind: Some(PythonEnvironmentKind::Homebrew), executable: Some(PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3.11")), - version: Some("3.11.9".to_string()), // This can change on CI, so we don't check it + version: Some("3.11.10".to_string()), // This can change on CI, so we don't check it symlinks: Some(vec![ PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3.11"), PathBuf::from("/home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11"), // On CI the Python version can change with minor updates, so we don't check the full version. - // PathBuf::from("/home/linuxbrew/.linuxbrew/Cellar/python@3.11/3.11.9/bin/python3.11"), + // PathBuf::from("/home/linuxbrew/.linuxbrew/Cellar/python@3.11/3.11.10/bin/python3.11"), ]), ..Default::default() };