modulefile 5.42 KB
Newer Older
bliven_s's avatar
bliven_s committed
1
#%Module1.0
Spencer Bliven's avatar
Spencer Bliven committed
2

bliven_s's avatar
bliven_s committed
3
module-whatis       "Conda package manager and Anaconda software distribution"
Spencer Bliven's avatar
Spencer Bliven committed
4 5
module-url          "https://www.anaconda.com/"
module-license      "3-clause BSD License and 3rd party software licenses. https://docs.continuum.io/anaconda/eula/"
6
module-maintainer   "Spencer Bliven <spencer.bliven@psi.ch> / Derek Feichtinger <derek.feichtinger@psi.ch>"
Spencer Bliven's avatar
Spencer Bliven committed
7 8

module-help         "
bliven_s's avatar
bliven_s committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Anaconda is a package manager, an environment manager, a Python/R data science
distribution, and a collection of over 1,500+ open source packages. Anaconda is
free and easy to install, and it offers free community support.

Conda is an open source package management system and environment management
system that runs on Windows, macOS and Linux. Conda quickly installs, runs and
updates packages and their dependencies. Conda easily creates, saves, loads and
switches between environments on your local computer. It was created for Python
programs, but it can package and distribute software for any language.

Conda as a package manager helps you find and install packages. If you need a
package that requires a different version of Python, you do not need to switch
to a different environment manager, because conda is also an environment
manager. With just a few commands, you can set up a totally separate
environment to run that different version of Python, while continuing to run
your usual version of Python in your normal environment.

This package provides the conda command (miniconda), as well as releases of the
Anaconda distribution, built against several python versions.
Spencer Bliven's avatar
Spencer Bliven committed
28 29
"

30 31 32 33 34 35 36 37 38 39
# this package has conflicts with all older psi python installations which
# integrated conda into the psi-python
conflict  psi-python27
conflict  psi-python34
conflict  psi-python35
conflict  psi-python36
conflict  psi-python37


# These paths are managed by the sourced conda file. Pmodules should not touch it
Spencer Bliven's avatar
Spencer Bliven committed
40
set dont-setenv { LD_LIBRARY_PATH }
41
set dont-setenv { PATH }
Spencer Bliven's avatar
Spencer Bliven committed
42 43 44 45 46 47 48 49 50 51 52 53 54

# Check for supported shell types
set shelltype [module-info shelltype]
switch -- $shelltype {
    "sh" {
    }
    default {
        puts stderr "Shells of type '$shelltype' are NOT supported!"
    }
}

switch [module-info mode] {
    "load" {
55 56 57 58
        #TODO check whether another conda version is present (conflicts)
        # pmodules itself seems to prevent loading the same module of a different version
        # but we need to prevent conflicts with a conda from a different source.

59
        # puts stderr "DEBUG: Using conda from $P/$V\n"
Spencer Bliven's avatar
Spencer Bliven committed
60
        puts stdout "source \"$PREFIX/conda/etc/profile.d/conda.sh\";\n"
bliven_s's avatar
bliven_s committed
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
        # Activate base? No: anaconda should just provide the conda tool
        #puts stdout "conda activate;\n"


        # Safety check! Warn if an admin loads anaconda on an auristor system
        catch {
            # Check if we're running auristor
            set afsversion [exec fs --version]
            if [regexp -nocase {^auristor} $afsversion] {

                # Admin groups for this module (regex format)
                set admins {sys.modules:administrators|sys.modules:psi_python}

                # Determine current user. Prefer klist, but fall back to $USER
                catch {
                    exec klist 2>/dev/null | sed -E -n {s/.*principal: ([^@]+)(@.*)?$/\1/p};
                } principal option
                if { [dict get $option -code] != 0} {
                    set principal $::env(USER)
                }

                # Determine whether the user belongs to one of the admin groups
                if [regexp $admins [exec pts mem $principal]] {
                    puts stderr "WARNING: You have loaded the anaconda module on an Auristor system. Do not install packages!"
                }
            }
        }
Spencer Bliven's avatar
Spencer Bliven committed
89
    }
90 91

    "unload" -
Spencer Bliven's avatar
Spencer Bliven committed
92
    "remove" {
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
        # Only run this if conda is in the PATH
        catch {exec which conda} result option
        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 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;}

            # 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 "$PREFIX/conda/condabin" | tr '\n' ':'); export PATH=${PATH%:};}

            # remove the conda function definitions
            unsetenv __conda_activate
            unsetenv __conda_hashr
            unsetenv __conda_reactivate
            unsetenv conda

            unsetenv CONDA_EXE
            unsetenv CONDA_PYTHON_EXE
            unsetenv CONDA_SHLVL
            unsetenv _CE_CONDA
        }
Spencer Bliven's avatar
Spencer Bliven committed
125 126 127
    }
}