diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a133f1b2..ea4631e6 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -45,7 +45,7 @@ jobs: - name: Set Python to PATH uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: "3.12" - name: Homebrew Python if: startsWith( matrix.os, 'macos') @@ -134,7 +134,7 @@ jobs: if: startsWith( matrix.os, 'ubuntu') || startsWith( matrix.os, 'macos') run: | pyenv install --list - pyenv install 3.13.0 3.12.7 3.8.20 + pyenv install 3.13.0 3.12.8 3.8.20 shell: bash # pyenv-win install list has not updated for a while @@ -248,7 +248,7 @@ jobs: if: startsWith( matrix.feature, 'ci-poetry') uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: "3.12" - name: Set Python 3.12 to PATH if: startsWith( matrix.feature, 'ci-poetry') @@ -304,48 +304,48 @@ jobs: virtualenvs-path: ~/my-custom-path installer-parallel: true - - name: Petry exe + - name: Poetry exe if: startsWith( matrix.feature, 'ci-poetry') run: which poetry shell: bash - - name: Petry config + - name: Poetry config if: startsWith( matrix.feature, 'ci-poetry') run: poetry config --list shell: bash - - name: Petry setup + - name: Poetry setup if: startsWith( matrix.feature, 'ci-poetry') # We want to have 2 envs for this poetry project 3.12 and 3.11. run: poetry init --name=pet-test --python=^3.11 -q -n shell: bash - - name: Petry virtual env setup 3.12 + - name: Poetry virtual env setup 3.12 if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'ubuntu') run: poetry env use 3.12 shell: bash - - name: Petry virtual env setup 3.12 + - name: Poetry virtual env setup 3.12 if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows') run: poetry env use $PYTHON_3_12_PATH shell: bash - - name: Petry virtual env setup 3.11 + - name: Poetry virtual env setup 3.11 if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'ubuntu') run: poetry env use 3.11 shell: bash - - name: Petry virtual env setup 3.11 + - name: Poetry virtual env setup 3.11 if: startsWith( matrix.feature, 'ci-poetry') && startsWith( matrix.os, 'windows') run: poetry env use $PYTHON_3_11_PATH shell: bash - - name: Petry list envs + - name: Poetry list envs if: startsWith( matrix.feature, 'ci-poetry') run: poetry env list shell: bash - - name: Petry pyproject.toml + - name: Poetry pyproject.toml if: startsWith( matrix.feature, 'ci-poetry') run: cat pyproject.toml shell: bash @@ -414,7 +414,7 @@ jobs: if: startsWith( matrix.image, 'homebrew') run: | # homebrew/brew:4.4.6 broke running `brew install` as root. - # As a workaround, running `brew update` and ignoring errors coming from it fixes `brew install`. + # As a workaround, running `brew update` and ignoring errors coming from it fixes `brew install`. brew update || true brew install python@3.12 python@3.11 shell: bash diff --git a/crates/pet-conda/src/conda_rc.rs b/crates/pet-conda/src/conda_rc.rs index 98990f8c..eb8fdb03 100644 --- a/crates/pet-conda/src/conda_rc.rs +++ b/crates/pet-conda/src/conda_rc.rs @@ -216,6 +216,7 @@ fn get_conda_conda_rc_from_path(conda_rc: &PathBuf) -> Option { if env_dirs.is_empty() && files.is_empty() { None } else { + trace!("conda_rc: {:?} with env_dirs {:?}", conda_rc, env_dirs); Some(Condarc { env_dirs, files }) } } diff --git a/crates/pet-conda/src/environment_locations.rs b/crates/pet-conda/src/environment_locations.rs index 4bd65c31..744da92c 100644 --- a/crates/pet-conda/src/environment_locations.rs +++ b/crates/pet-conda/src/environment_locations.rs @@ -75,6 +75,7 @@ fn get_conda_environment_paths_from_conda_rc(env_vars: &EnvVariables) -> Vec Vec Option { let conda_exe = resolve_symlink(&conda_exe).unwrap_or(conda_exe); if let Some(cmd_line) = conda_exe.parent() { if let Some(conda_dir) = cmd_line.file_name() { - if conda_dir.to_ascii_lowercase() == "bin" - || conda_dir.to_ascii_lowercase() == "scripts" + if conda_dir.to_string_lossy().to_lowercase() == "bin" + || conda_dir.to_string_lossy().to_lowercase() == "scripts" { if let Some(conda_dir) = cmd_line.parent() { // Ensure the casing of the paths are correct. diff --git a/crates/pet-core/src/os_environment.rs b/crates/pet-core/src/os_environment.rs index f9ef61a3..65ea094d 100644 --- a/crates/pet-core/src/os_environment.rs +++ b/crates/pet-core/src/os_environment.rs @@ -133,8 +133,18 @@ impl Environment for EnvironmentApi { } } +#[cfg(windows)] +fn get_user_home() -> Option { + let home = env::var("USERPROFILE").or_else(|_| env::var("HOME")); + match home { + Ok(home) => Some(norm_case(PathBuf::from(home))), + Err(_) => None, + } +} + +#[cfg(unix)] fn get_user_home() -> Option { - let home = env::var("HOME").or_else(|_| env::var("USERPROFILE")); + let home = env::var("HOME"); match home { Ok(home) => Some(norm_case(PathBuf::from(home))), Err(_) => None, diff --git a/crates/pet-poetry/src/pyproject_toml.rs b/crates/pet-poetry/src/pyproject_toml.rs index c110f3f8..de5dc69c 100644 --- a/crates/pet-poetry/src/pyproject_toml.rs +++ b/crates/pet-poetry/src/pyproject_toml.rs @@ -8,6 +8,7 @@ use std::{ use log::{error, trace}; +#[derive(Debug)] pub struct PyProjectToml { pub name: String, } @@ -18,11 +19,13 @@ impl PyProjectToml { PyProjectToml { name } } pub fn find(path: &Path) -> Option { + trace!("Finding poetry file in {:?}", path); parse(&path.join("pyproject.toml")) } } fn parse(file: &Path) -> Option { + trace!("Parsing poetry file: {:?}", file); let contents = fs::read_to_string(file).ok()?; parse_contents(&contents, file) } @@ -38,7 +41,23 @@ fn parse_contents(contents: &str, file: &Path) -> Option { } } } - name.map(|name| PyProjectToml::new(name, file.into())) + + match name { + Some(name) => Some(PyProjectToml::new(name, file.into())), + None => { + trace!( + "Poetry project name not found in {:?}, trying the new format", + file + ); + let mut name = None; + if let Some(project) = value.get("project") { + if let Some(name_value) = project.get("name") { + name = name_value.as_str().map(|s| s.to_string()); + } + } + name.map(|name| PyProjectToml::new(name, file.into())) + } + } } Err(e) => { error!("Error parsing toml file: {:?}", e); diff --git a/crates/pet/tests/ci_homebrew_container.rs b/crates/pet/tests/ci_homebrew_container.rs index 1e16e3ec..9b0e67ea 100644 --- a/crates/pet/tests/ci_homebrew_container.rs +++ b/crates/pet/tests/ci_homebrew_container.rs @@ -72,7 +72,7 @@ fn verify_python_in_homebrew_contaner() { let python3_12 = PythonEnvironment { kind: Some(PythonEnvironmentKind::Homebrew), executable: Some(PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3.12")), - version: Some("3.12.7".to_string()), // This can change on CI, so we don't check it + version: Some("3.12.8".to_string()), // This can change on CI, so we don't check it symlinks: Some(vec![ // For older versions of Python, we do not have a tonne of symlinks, // E.g. for 3.12.7 (which was the latest at some point, at a lot of symlinks) @@ -88,7 +88,7 @@ fn verify_python_in_homebrew_contaner() { let python3_11 = PythonEnvironment { kind: Some(PythonEnvironmentKind::Homebrew), executable: Some(PathBuf::from("/home/linuxbrew/.linuxbrew/bin/python3.11")), - version: Some("3.11.10".to_string()), // This can change on CI, so we don't check it + version: Some("3.11.11".to_string()), // This can change on CI, so we don't check it symlinks: Some(vec![ // For older versions of Python, we do not have a tonne of symlinks, // E.g. for 3.12.7 (which was the latest at some point, at a lot of symlinks)