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

Resolve with paths not just exe #140

Merged
merged 10 commits into from
Aug 21, 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
2 changes: 1 addition & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion crates/pet/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -27,6 +27,17 @@ pub fn resolve_environment(
locators: &Arc<Vec<Arc<dyn Locator>>>,
os_environment: &dyn Environment,
) -> Option<ResolvedEnvironment> {
// 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<PathBuf> = get_search_paths_from_env_variables(os_environment);
Expand Down
4 changes: 2 additions & 2 deletions 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.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"),
Expand All @@ -61,7 +61,7 @@ fn verify_python_in_homebrew_contaner() {
PathBuf::from("/home/linuxbrew/.linuxbrew/opt/[email protected]/bin/python3"),
PathBuf::from("/home/linuxbrew/.linuxbrew/opt/[email protected]/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/[email protected]/3.12.4/bin/python3.12"),
// PathBuf::from("/home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.12.5/bin/python3.12"),
]),
..Default::default()
};
Expand Down
Loading