Skip to content
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
26 changes: 13 additions & 13 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/pet-conda/src/conda_rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ fn get_conda_conda_rc_from_path(conda_rc: &PathBuf) -> Option<Condarc> {
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 })
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/pet-conda/src/environment_locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn get_conda_environment_paths_from_conda_rc(env_vars: &EnvVariables) -> Vec<Pat
let mut env_dirs = vec![];
for rc_file_dir in get_conda_rc_search_paths(env_vars) {
if !rc_file_dir.exists() {
trace!(".condarc not found ({:?})", rc_file_dir);
continue;
}

Expand Down Expand Up @@ -111,7 +112,7 @@ fn get_conda_environment_paths_from_conda_rc(env_vars: &EnvVariables) -> Vec<Pat
);
env_dirs.append(&mut conda_rc.env_dirs.clone());
} else {
trace!("No Conda environments in .condarc");
trace!("No Conda environments in .condarc {:?}", env_dirs);
}
env_dirs
}
Expand Down
4 changes: 2 additions & 2 deletions crates/pet-conda/src/environments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ fn get_conda_dir_from_cmd(cmd_line: String) -> Option<PathBuf> {
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.
Expand Down
12 changes: 11 additions & 1 deletion crates/pet-core/src/os_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,18 @@ impl Environment for EnvironmentApi {
}
}

#[cfg(windows)]
fn get_user_home() -> Option<PathBuf> {
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<PathBuf> {
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,
Expand Down
21 changes: 20 additions & 1 deletion crates/pet-poetry/src/pyproject_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{

use log::{error, trace};

#[derive(Debug)]
pub struct PyProjectToml {
pub name: String,
}
Expand All @@ -18,11 +19,13 @@ impl PyProjectToml {
PyProjectToml { name }
}
pub fn find(path: &Path) -> Option<Self> {
trace!("Finding poetry file in {:?}", path);
parse(&path.join("pyproject.toml"))
}
}

fn parse(file: &Path) -> Option<PyProjectToml> {
trace!("Parsing poetry file: {:?}", file);
let contents = fs::read_to_string(file).ok()?;
parse_contents(&contents, file)
}
Expand All @@ -38,7 +41,23 @@ fn parse_contents(contents: &str, file: &Path) -> Option<PyProjectToml> {
}
}
}
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);
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 @@ -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)
Expand All @@ -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)
Expand Down
Loading