Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Jun 6, 2024
1 parent 2d38e6b commit 8ea4390
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ jobs:
curl https://pyenv.run | bash
echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
echo "PATH=$HOME/.pyenv/bin:$PATH" >> $GITHUB_ENV
eval "$(pyenv virtualenv-init -)"
pyenv virtualenv 3.12 my-virtual-env-3.12
shell: bash

- name: Check Pyenv version
Expand All @@ -146,6 +144,13 @@ jobs:
pyenv install 3.10.5 3.8.10
shell: bash

- name: Create pyenv-virtualenv envs
if: startsWith( matrix.os, 'ubuntu') || startsWith( matrix.os, 'macos')
run: |
eval "$(pyenv virtualenv-init -)"
pyenv virtualenv 3.12 my-virtual-env-3.12
shell: bash

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
8 changes: 6 additions & 2 deletions crates/pet-global-virtualenvs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn get_global_virtualenv_dirs(
for dir in [
PathBuf::from("envs"),
PathBuf::from(".direnv"),
PathBuf::from(".venvs"),
PathBuf::from(".virtualenvs"),
PathBuf::from(".venvs"), // Used by pipenv, https://pipenv.pypa.io/en/latest/virtualenv.html
PathBuf::from(".virtualenvs"), // Useb by virtualenvwrapper, https://virtualenvwrapper.readthedocs.io/en/latest/install.html#shell-startup-file
PathBuf::from(".local").join("share").join("virtualenvs"),
] {
let venv_dir = home.join(dir);
Expand All @@ -36,6 +36,10 @@ fn get_global_virtualenv_dirs(
if fs::metadata(&envs).is_ok() {
venv_dirs.push(envs);
}
let envs = PathBuf::from("envs");
if fs::metadata(&envs).is_ok() {
venv_dirs.push(envs);
}
}
}

Expand Down
53 changes: 53 additions & 0 deletions crates/pet-pyenv/tests/ci_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use std::path::PathBuf;

use serde::Deserialize;

mod common;

#[cfg(unix)]
#[cfg_attr(feature = "ci", test)]
#[allow(dead_code)]
// We should detect the conda install along with the base env
fn detect_virtual_env_wrapper() {
if cfg!(target_os = "linux") {
// Code to execute if OS is Linux
} else {
// Code to execute if OS is not Linux
}
use pet_conda::Conda;
use pet_core::{
manager::EnvManagerType, os_environment::EnvironmentApi,
python_environment::PythonEnvironmentCategory, Locator,
};
use std::path::PathBuf;

let env = EnvironmentApi::new();

let conda = Conda::from(&env);
let result = conda.find().unwrap();

assert_eq!(result.managers.len(), 1);

let info = get_conda_info();
let conda_dir = PathBuf::from(info.conda_prefix.clone());
let manager = &result.managers[0];
assert_eq!(manager.executable, conda_dir.join("bin").join("conda"));
assert_eq!(manager.tool, EnvManagerType::Conda);
assert_eq!(manager.version, info.conda_version.into());

let env = &result
.environments
.iter()
.find(|e| e.name == Some("base".into()))
.unwrap();
assert_eq!(env.prefix, conda_dir.clone().into());
assert_eq!(env.name, Some("base".into()));
assert_eq!(env.category, PythonEnvironmentCategory::Conda);
assert_eq!(env.executable, Some(conda_dir.join("bin").join("python")));
assert_eq!(env.version, Some(get_version(&info.python_version)));

assert_eq!(env.manager, Some(manager.clone()));
}

0 comments on commit 8ea4390

Please sign in to comment.