diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..85ae476c --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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}" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..3dfe321b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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", + "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" +} \ No newline at end of file diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 00000000..f707f938 --- /dev/null +++ b/.devcontainer/setup.sh @@ -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}" diff --git a/crates/pet-conda/src/lib.rs b/crates/pet-conda/src/lib.rs index f8465a95..cc0d0318 100644 --- a/crates/pet-conda/src/lib.rs +++ b/crates/pet-conda/src/lib.rs @@ -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); @@ -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. diff --git a/crates/pet-conda/src/utils.rs b/crates/pet-conda/src/utils.rs index aaf9e898..46e93833 100644 --- a/crates/pet-conda/src/utils.rs +++ b/crates/pet-conda/src/utils.rs @@ -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() diff --git a/crates/pet/Cargo.toml b/crates/pet/Cargo.toml index 9e8cb4cb..10a56569 100644 --- a/crates/pet/Cargo.toml +++ b/crates/pet/Cargo.toml @@ -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] regex = "1.10.4" lazy_static = "1.4.0" diff --git a/crates/pet/src/find.rs b/crates/pet/src/find.rs index 6509b8ed..ffc5bc5e 100644 --- a/crates/pet/src/find.rs +++ b/crates/pet/src/find.rs @@ -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);