diff --git a/Programming/anaconda/README.md b/Programming/anaconda/README.md index 61ed522..10ac800 100644 --- a/Programming/anaconda/README.md +++ b/Programming/anaconda/README.md @@ -3,7 +3,7 @@ ## Concepts * The anaconda module just provides the **conda** package management tool together with its directory infrastructure which contains *conda environments* and a cache of downloaded packages - * Python and user software is provided in **conda environments**. These environments are located within the directory tree belonging to the anaconda module, e.g. `/afs/psi.ch/sys/psi.merlin/Programming/anaconda/2019.03/conda/envs/` + * Python and user software is provided in **conda environments**. These environments are located within the directory tree belonging to the anaconda module, e.g. `/afs/psi.ch/sys/psi.merlin/Programming/anaconda/2019.07/conda/envs/` * The software in these environments can be accessed by users through 1) loading the anaconda module and then using `conda activate somemodule_py36` 1) a seperate pmodule that transparently switches to that installed environment by just setting the correct PATH to the python binary. @@ -21,14 +21,14 @@ In the simplest case, the environment can be created by conda alone. First load the anaconda module to get access to the conda package installer and the install environment. ``` -module load anaconda/2019.03 +module load anaconda/2019.07 ``` Define your installation in a `conda YAML` file and place it inside the buildblock tree ``` -cd buildblocks/Programming/anaconda/2019.03/conda-env-defs +cd buildblocks/Programming/anaconda/2019.07/conda-env-defs mkdir datascience_36 vim datascience_36/datascience_36.yml ``` diff --git a/Programming/anaconda/modulefile b/Programming/anaconda/modulefile index 57ae683..763a912 100644 --- a/Programming/anaconda/modulefile +++ b/Programming/anaconda/modulefile @@ -69,14 +69,22 @@ switch [module-info mode] { if { [dict get $option -code] != 0 } { puts stderr "Error: cannot cleanly unload anaconda: conda is not in the PATH" } else { - # if the user has invoked this from a subshell, the conda functions may - # not be defined, so we need to reload the environment - puts stdout {if [[ x$(command -v conda) != xconda ]];then source $(conda info --base)/etc/profile.d/conda.sh; fi;} + # if the user has invoked this from a subshell, the conda + # functions may not be defined even though a conda + # executable is still in the path ! One could try the + # following, but currently we leave it commented. + # puts stdout {if [[ x$(command -v conda) != xconda ]];then source $(conda info --base)/etc/profile.d/conda.sh; fi;} - # Deactivate all layers of active conda environments - puts stdout {while [[ "${CONDA_SHLVL:-0}" -gt 0 ]]; do conda deactivate; done;} + # If the conda env is intact (conda defined as a function), then + # deactivate all layers of active conda environments + puts stdout {if [[ x$(command -v conda) == xconda ]]; then while [[ "${CONDA_SHLVL:-0}" -gt 0 ]]; do [[ $PMODULES_DEBUG == 1 ]] && echo "unloading conda env $CONDA_DEFAULT_ENV..." >&2; conda deactivate; [[ $PMODULES_DEBUG == 1 ]] && echo $PATH >&2; done; fi;} + + # the path cleaning cannot use tcl remove-path, since at this point tcl + # is not aware that the above bash statements will have modified the path + # upon the eval that is done by the outer "module" function. + + puts stdout {PATH=$(echo $PATH| tr ':' '\n' | grep -v "$mydel" | tr '\n' ':'); export PATH=${PATH%:};} - remove-path PATH $PREFIX/conda/condabin # remove the conda function definitions unsetenv __conda_activate unsetenv __conda_hashr