Skip to content

Fix conda detection #55

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

Merged
merged 9 commits into from
Jun 26, 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
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Based off, https://github.com/github/codespaces-jupyter
FROM mcr.microsoft.com/devcontainers/universal:2

RUN apt install curl -y
RUN sh -c "$(curl -fsSL https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-t powerlevel10k/powerlevel10k \
-p git \
-p git-extras \
-p https://github.com/zsh-users/zsh-completions
RUN git clone https://github.com/romkatv/powerlevel10k $HOME/.oh-my-zsh/custom/themes/powerlevel10k
RUN curl https://raw.githubusercontent.com/DonJayamanne/vscode-jupyter/containerChanges/.devcontainer/.p10k.zsh > ~/.p10k.zsh
RUN echo "# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh." >> ~/.zshrc
RUN echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> ~/.zshrc
# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
ENV PATH="/root/.cargo/bin:${PATH}"
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Based off, https://github.com/github/codespaces-jupyter
// Making this the top level container so it works on codespaces,
// Cannot always use locally as this is only x64 compatible
"name": "codespaces-jupyter",
"image": "mcr.microsoft.com/devcontainers/universal:2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a dev container for testing of this scenario identified

"waitFor": "onCreateCommand",
"postCreateCommand": "bash ./.devcontainer/setup.sh",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python@prerelease",
"esbenp.prettier-vscode",
"rust-lang.rust-analyzer",
"EditorConfig.EditorConfig"
]
}
},
"workspaceFolder": "/workspaces/python-environment-tools"
}
17 changes: 17 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash


# sh -c "$(curl -fsSL https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
# -t powerlevel10k/powerlevel10k \
# -p git \
# -p git-extras \
# -p https://github.com/zsh-users/zsh-completions
# git clone https://github.com/romkatv/powerlevel10k $HOME/.oh-my-zsh/custom/themes/powerlevel10k
# curl https://raw.githubusercontent.com/DonJayamanne/vscode-jupyter/containerChanges/.devcontainer/.p10k.zsh > ~/.p10k.zsh
# echo "# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh." >> ~/.zshrc
# echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> ~/.zshrc

# Install Rust
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
PATH="/root/.cargo/bin:${PATH}"
2 changes: 1 addition & 1 deletion crates/pet-conda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ impl Locator for Conda {
if manager.is_none() {
// 4.1 Build the manager from the conda dir if we do not have it.
if let Some(conda_manager) = CondaManager::from(conda_dir) {
reporter.report_manager(&conda_manager.to_manager());
let mut managers = self.managers.lock().unwrap();
managers.insert(conda_dir.to_path_buf().clone(), conda_manager.clone());
manager = Some(conda_manager);
Expand All @@ -285,6 +284,7 @@ impl Locator for Conda {
);
let mut environments = self.environments.lock().unwrap();
environments.insert(prefix.clone(), env.clone());
reporter.report_manager(&manager.to_manager());
reporter.report_environment(&env);
} else {
// We will still return the conda env even though we do not have the manager.
Expand Down
9 changes: 5 additions & 4 deletions crates/pet-conda/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use std::{
path::{Path, PathBuf},
};

// conda-meta must exist as this contains a mandatory `history` file.
/// conda-meta must exist as this contains a mandatory `history` file.
pub fn is_conda_install(path: &Path) -> bool {
path.join("envs").metadata().is_ok() && path.join("conda-meta").metadata().is_ok()
(path.join("condabin").metadata().is_ok() || path.join("envs").metadata().is_ok())
&& path.join("conda-meta").metadata().is_ok()
}

// conda-meta must exist as this contains a mandatory `history` file.
// The root conda installation folder is also a conda environment (its the base environment).
/// conda-meta must exist as this contains a mandatory `history` file.
/// The root conda installation folder is also a conda environment (its the base environment).
pub fn is_conda_env(path: &Path) -> bool {
if let Ok(metadata) = fs::metadata(path.join("conda-meta")) {
metadata.is_dir()
Expand Down
2 changes: 1 addition & 1 deletion crates/pet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ clap = { version = "4.5.4", features = ["derive", "cargo"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"

[dev_dependencies]
[dev-dependencies]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New format is dev-depdencies

regex = "1.10.4"
lazy_static = "1.4.0"

Expand Down
3 changes: 3 additions & 0 deletions crates/pet/src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ fn identify_python_executables_using_locators(
identify_python_environment_using_locators(&env, locators, fallback_category)
{
reporter.report_environment(&env);
if let Some(manager) = env.manager {
reporter.report_manager(&manager);
}
continue;
} else {
warn!("Unknown Python Env {:?}", executable);
Expand Down
Loading