1- set -e
2-
3- # Setup conda
41CONDA_PROFILE=" ${CONDA_DIR} /etc/profile.d/conda.sh"
5- echo " Activating profile: ${CONDA_PROFILE} "
6- test -f $CONDA_PROFILE && . $CONDA_PROFILE
72
8- # Setup micromamba
9- eval $( micromamba shell hook -s posix -r ${CONDA_DIR} )
3+ if [ -f $CONDA_PROFILE ]; then
4+ # Setup conda
5+ echo " Activating profile: ${CONDA_PROFILE} "
6+ source $CONDA_PROFILE
107
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
8+ # Setup micromamba
9+ eval $( micromamba shell hook -s posix -r ${CONDA_DIR} )
2010
21- # Activate the environment
22- if [[ " ${KERNEL_PYTHON_PREFIX} " != " ${NB_PYTHON_PREFIX} " ]]; then
23- # if the kernel is a separate env, stack them
24- # so both are on PATH, notebook first
25- mamba activate ${KERNEL_PYTHON_PREFIX}
26- mamba activate --stack ${NB_PYTHON_PREFIX}
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
2720
28- # even though it's second on $PATH
29- # make sure CONDA_DEFAULT_ENV is the *kernel* env
30- # so that `!conda install PKG` installs in the kernel env
31- # where user packages are installed, not the notebook env
32- # which only contains UI when the two are different
33- export CONDA_DEFAULT_ENV=" ${KERNEL_PYTHON_PREFIX} "
34- else
35- mamba activate ${NB_PYTHON_PREFIX}
36- fi
21+ # Activate the environment
22+ if [[ " ${KERNEL_PYTHON_PREFIX} " != " ${NB_PYTHON_PREFIX} " ]]; then
23+ # if the kernel is a separate env, stack them
24+ # so both are on PATH, notebook first
25+ mamba activate ${KERNEL_PYTHON_PREFIX}
26+ mamba activate --stack ${NB_PYTHON_PREFIX}
3727
38- set +e
28+ # even though it's second on $PATH
29+ # make sure CONDA_DEFAULT_ENV is the *kernel* env
30+ # so that `!conda install PKG` installs in the kernel env
31+ # where user packages are installed, not the notebook env
32+ # which only contains UI when the two are different
33+ export CONDA_DEFAULT_ENV=" ${KERNEL_PYTHON_PREFIX} "
34+ else
35+ mamba activate ${NB_PYTHON_PREFIX}
36+ fi
37+
38+ else
39+ echo " Conda compatible environment not loaded due to"
40+ echo
41+ echo " - Mising file ${CONDA_PROFILE} "
42+ echo
43+ echo " Some tools might NOT be available!"
44+ fi
0 commit comments