Skip to content

Commit 5a61997

Browse files
authored
Merge pull request #1419 from jjerphan/maint/adapt-mamba-activation
maint: Adapt mamba activation
2 parents 3c1ed3c + f968689 commit 5a61997

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

repo2docker/buildpacks/conda/activate-conda.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
# enable conda and activate the notebook environment
2-
set -e
1+
set -ex
2+
3+
# Setup conda
4+
CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/conda.sh"
5+
echo "Activating profile: ${CONDA_PROFILE}"
6+
test -f $CONDA_PROFILE && . $CONDA_PROFILE
7+
8+
# Setup micromamba
39
eval $(micromamba shell hook -s posix -r ${CONDA_DIR})
4-
for name in conda mamba; do
5-
CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/${name}.sh"
6-
echo "Activating profile: ${CONDA_PROFILE}"
7-
test -f $CONDA_PROFILE && . $CONDA_PROFILE
8-
done
10+
11+
# Setup mamba
12+
export MAMBA_ROOT_PREFIX="${CONDA_DIR}"
13+
__mamba_setup="$("${CONDA_DIR}/bin/mamba" shell hook --shell posix 2> /dev/null)"
14+
if [ $? -eq 0 ]; then
15+
eval "$__mamba_setup"
16+
else
17+
alias mamba="${CONDA_DIR}/bin/mamba" # Fallback on help from mamba activate
18+
fi
19+
unset __mamba_setup
20+
21+
# Activate the environment
922
if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
1023
# if the kernel is a separate env, stack them
1124
# so both are on PATH, notebook first
@@ -22,4 +35,4 @@ else
2235
mamba activate ${NB_PYTHON_PREFIX}
2336
fi
2437

25-
set +e
38+
set +ex

0 commit comments

Comments
 (0)