diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a1cbdfb4..0ba26d7c 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.4 3.8.19 + pyenv install 3.12.5 3.8.19 shell: bash # pyenv-win install list has not updated for a while diff --git a/crates/pet/src/resolve.rs b/crates/pet/src/resolve.rs index c99c1675..673f48a6 100644 --- a/crates/pet/src/resolve.rs +++ b/crates/pet/src/resolve.rs @@ -12,7 +12,7 @@ use pet_core::{ Locator, }; use pet_env_var_path::get_search_paths_from_env_variables; -use pet_python_utils::env::ResolvedPythonEnv; +use pet_python_utils::{env::ResolvedPythonEnv, executable::find_executable}; use crate::locators::identify_python_environment_using_locators; @@ -27,6 +27,17 @@ pub fn resolve_environment( locators: &Arc>>, os_environment: &dyn Environment, ) -> Option { + // First check if executable is actually a file or a path. + let mut executable = executable.to_owned(); + if executable.is_dir() { + executable = match find_executable(&executable) { + Some(exe) => exe, + None => { + warn!("Could not find Python executable in {:?}", executable); + executable + } + }; + } // First check if this is a known environment let env = PythonEnv::new(executable.to_owned(), None, None); let global_env_search_paths: Vec = get_search_paths_from_env_variables(os_environment); diff --git a/crates/pet/tests/ci_homebrew_container.rs b/crates/pet/tests/ci_homebrew_container.rs index 54fa0bc1..b7032623 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.4".to_string()), // This can change on CI, so we don't check it + version: Some("3.12.5".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,7 +61,7 @@ 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.4/bin/python3.12"), + // PathBuf::from("/home/linuxbrew/.linuxbrew/Cellar/python@3.12/3.12.5/bin/python3.12"), ]), ..Default::default() };