Skip to content

Commit b710945

Browse files
authored
Fix conda detection (#55)
1 parent 4ef6b00 commit b710945

File tree

7 files changed

+64
-6
lines changed

7 files changed

+64
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Based off, https://github.com/github/codespaces-jupyter
2+
FROM mcr.microsoft.com/devcontainers/universal:2
3+
4+
RUN apt install curl -y
5+
RUN sh -c "$(curl -fsSL https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
6+
-t powerlevel10k/powerlevel10k \
7+
-p git \
8+
-p git-extras \
9+
-p https://github.com/zsh-users/zsh-completions
10+
RUN git clone https://github.com/romkatv/powerlevel10k $HOME/.oh-my-zsh/custom/themes/powerlevel10k
11+
RUN curl https://raw.githubusercontent.com/DonJayamanne/vscode-jupyter/containerChanges/.devcontainer/.p10k.zsh > ~/.p10k.zsh
12+
RUN echo "# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh." >> ~/.zshrc
13+
RUN echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> ~/.zshrc
14+
# Install Rust
15+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
16+
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
17+
ENV PATH="/root/.cargo/bin:${PATH}"

.devcontainer/devcontainer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Based off, https://github.com/github/codespaces-jupyter
3+
// Making this the top level container so it works on codespaces,
4+
// Cannot always use locally as this is only x64 compatible
5+
"name": "codespaces-jupyter",
6+
"image": "mcr.microsoft.com/devcontainers/universal:2",
7+
"waitFor": "onCreateCommand",
8+
"postCreateCommand": "bash ./.devcontainer/setup.sh",
9+
"customizations": {
10+
"vscode": {
11+
"extensions": [
12+
"ms-python.python@prerelease",
13+
"esbenp.prettier-vscode",
14+
"rust-lang.rust-analyzer",
15+
"EditorConfig.EditorConfig"
16+
]
17+
}
18+
},
19+
"workspaceFolder": "/workspaces/python-environment-tools"
20+
}

.devcontainer/setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
4+
# sh -c "$(curl -fsSL https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
5+
# -t powerlevel10k/powerlevel10k \
6+
# -p git \
7+
# -p git-extras \
8+
# -p https://github.com/zsh-users/zsh-completions
9+
# git clone https://github.com/romkatv/powerlevel10k $HOME/.oh-my-zsh/custom/themes/powerlevel10k
10+
# curl https://raw.githubusercontent.com/DonJayamanne/vscode-jupyter/containerChanges/.devcontainer/.p10k.zsh > ~/.p10k.zsh
11+
# echo "# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh." >> ~/.zshrc
12+
# echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> ~/.zshrc
13+
14+
# Install Rust
15+
curl https://sh.rustup.rs -sSf | sh -s -- -y
16+
echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
17+
PATH="/root/.cargo/bin:${PATH}"

crates/pet-conda/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ impl Locator for Conda {
270270
if manager.is_none() {
271271
// 4.1 Build the manager from the conda dir if we do not have it.
272272
if let Some(conda_manager) = CondaManager::from(conda_dir) {
273-
reporter.report_manager(&conda_manager.to_manager());
274273
let mut managers = self.managers.lock().unwrap();
275274
managers.insert(conda_dir.to_path_buf().clone(), conda_manager.clone());
276275
manager = Some(conda_manager);
@@ -285,6 +284,7 @@ impl Locator for Conda {
285284
);
286285
let mut environments = self.environments.lock().unwrap();
287286
environments.insert(prefix.clone(), env.clone());
287+
reporter.report_manager(&manager.to_manager());
288288
reporter.report_environment(&env);
289289
} else {
290290
// We will still return the conda env even though we do not have the manager.

crates/pet-conda/src/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ use std::{
66
path::{Path, PathBuf},
77
};
88

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

14-
// conda-meta must exist as this contains a mandatory `history` file.
15-
// The root conda installation folder is also a conda environment (its the base environment).
15+
/// conda-meta must exist as this contains a mandatory `history` file.
16+
/// The root conda installation folder is also a conda environment (its the base environment).
1617
pub fn is_conda_env(path: &Path) -> bool {
1718
if let Ok(metadata) = fs::metadata(path.join("conda-meta")) {
1819
metadata.is_dir()

crates/pet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ clap = { version = "4.5.4", features = ["derive", "cargo"] }
3838
serde = { version = "1.0.152", features = ["derive"] }
3939
serde_json = "1.0.93"
4040

41-
[dev_dependencies]
41+
[dev-dependencies]
4242
regex = "1.10.4"
4343
lazy_static = "1.4.0"
4444

crates/pet/src/find.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ fn identify_python_executables_using_locators(
307307
identify_python_environment_using_locators(&env, locators, fallback_category)
308308
{
309309
reporter.report_environment(&env);
310+
if let Some(manager) = env.manager {
311+
reporter.report_manager(&manager);
312+
}
310313
continue;
311314
} else {
312315
warn!("Unknown Python Env {:?}", executable);

0 commit comments

Comments
 (0)