From 3171ebcfdad5ccd5fbec4b10a5729c6c38a16cec Mon Sep 17 00:00:00 2001 From: Spencer Bliven Date: Thu, 28 Mar 2019 10:25:49 +0100 Subject: [PATCH 1/3] Start anaconda build module Not currently tested pending AFS volume creation. Derives from EM/crYOLO. --- Programming/anaconda/build | 42 +++++++++++++++++++ Programming/anaconda/files/config-2018.12.sh | 9 ++++ Programming/anaconda/files/variants | 2 + Programming/anaconda/modulefile | 43 ++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100755 Programming/anaconda/build create mode 100644 Programming/anaconda/files/config-2018.12.sh create mode 100644 Programming/anaconda/files/variants create mode 100644 Programming/anaconda/modulefile diff --git a/Programming/anaconda/build b/Programming/anaconda/build new file mode 100755 index 0000000..772faa4 --- /dev/null +++ b/Programming/anaconda/build @@ -0,0 +1,42 @@ +#!/usr/bin/env modbuild + +pbuild::add_to_group 'Programming' +pbuild::prep() { + echo "prepping" + source "${BUILDBLOCK_DIR}/files/config-$V.sh" + + mkdir -p "$SRC_DIR" + echo curl -fsSLo "$SRC_DIR/miniconda.sh" "https://repo.anaconda.com/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" + curl -fsSLo "$SRC_DIR/miniconda.sh" "https://repo.anaconda.com/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" +} + +pbuild::configure() { + : +} + +pbuild::compile() { + : +} + +pbuild::install() { + source "${BUILDBLOCK_DIR}/files/config-$V.sh" + + mkdir -p $PREFIX + + # Install conda + bash "$SRC_DIR/miniconda.sh" -b -p $PREFIX/conda + + # Load conda + source "$PREFIX/conda/etc/profile.d/conda.sh" + + # Install anaconda versions + for PY in "${PYTHON_VERSION[@]}"; do + conda install -y anaconda=$V python=$PY + done + + # Deactivate + source deactivate + + # Unload conda; + #unset $(set|sed -rn 's/^(_?conda[a-z_]*).*$/\1/pI'); +} diff --git a/Programming/anaconda/files/config-2018.12.sh b/Programming/anaconda/files/config-2018.12.sh new file mode 100644 index 0000000..f1ba9d1 --- /dev/null +++ b/Programming/anaconda/files/config-2018.12.sh @@ -0,0 +1,9 @@ +# version-specific settings + +# Miniconda version. Defaults to "latest" +# Should match the version distributed with anaconda +CONDA_VERSION=4.5.12 + +# List of python versions to install +PYTHON_VERSIONS=(2.7) + diff --git a/Programming/anaconda/files/variants b/Programming/anaconda/files/variants new file mode 100644 index 0000000..7310e93 --- /dev/null +++ b/Programming/anaconda/files/variants @@ -0,0 +1,2 @@ +anaconda/2018.12 unstable + diff --git a/Programming/anaconda/modulefile b/Programming/anaconda/modulefile new file mode 100644 index 0000000..e9e240f --- /dev/null +++ b/Programming/anaconda/modulefile @@ -0,0 +1,43 @@ +#%Module + +module-whatis "Anaconda software distribution and conda package manager" +module-url "https://www.anaconda.com/" +module-license "3-clause BSD License and 3rd party software licenses. https://docs.continuum.io/anaconda/eula/" +module-maintainer "Spencer Bliven " + +module-help " +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. +" + +set dont-setenv { LD_LIBRARY_PATH } + +# 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" { + puts stdout "source \"$PREFIX/conda/etc/profile.d/conda.sh\";\n" + } + "unload" - + "remove" { + # Deactivate + puts stderr "which deactivate && source deactivate || source $PREFIX/conda/bin/deactivate;\n" + + # Unload conda + puts stdout {unset $(set|sed -rn 's/^(_?conda[a-z_]*).*$/\1/pI');} + } +} + From f06815bd3d922e28d4007216683c00565ef08c94 Mon Sep 17 00:00:00 2001 From: Spencer Bliven Date: Mon, 1 Apr 2019 13:41:14 +0200 Subject: [PATCH 2/3] Removing python installation from anaconda build script. This would be better done in dependent modules. --- Programming/anaconda/build | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Programming/anaconda/build b/Programming/anaconda/build index 772faa4..1682e85 100755 --- a/Programming/anaconda/build +++ b/Programming/anaconda/build @@ -2,7 +2,6 @@ pbuild::add_to_group 'Programming' pbuild::prep() { - echo "prepping" source "${BUILDBLOCK_DIR}/files/config-$V.sh" mkdir -p "$SRC_DIR" @@ -25,18 +24,4 @@ pbuild::install() { # Install conda bash "$SRC_DIR/miniconda.sh" -b -p $PREFIX/conda - - # Load conda - source "$PREFIX/conda/etc/profile.d/conda.sh" - - # Install anaconda versions - for PY in "${PYTHON_VERSION[@]}"; do - conda install -y anaconda=$V python=$PY - done - - # Deactivate - source deactivate - - # Unload conda; - #unset $(set|sed -rn 's/^(_?conda[a-z_]*).*$/\1/pI'); } From 8ce24107fc3ef00c4cd068bd62260f3c4d1bc7f1 Mon Sep 17 00:00:00 2001 From: Spencer Bliven Date: Mon, 8 Apr 2019 16:55:09 +0200 Subject: [PATCH 3/3] Update anaconda module - Update build script with best practices for variables, download location, etc. - Format modulefile info - Activate base environment by default - More robust unloading script --- Programming/anaconda/build | 17 +++++------ Programming/anaconda/files/config-2018.12.sh | 3 -- Programming/anaconda/modulefile | 32 +++++++++++++++----- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Programming/anaconda/build b/Programming/anaconda/build index 1682e85..91c547e 100755 --- a/Programming/anaconda/build +++ b/Programming/anaconda/build @@ -1,12 +1,12 @@ #!/usr/bin/env modbuild pbuild::add_to_group 'Programming' -pbuild::prep() { - source "${BUILDBLOCK_DIR}/files/config-$V.sh" - mkdir -p "$SRC_DIR" - echo curl -fsSLo "$SRC_DIR/miniconda.sh" "https://repo.anaconda.com/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" - curl -fsSLo "$SRC_DIR/miniconda.sh" "https://repo.anaconda.com/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" +source "${BUILDBLOCK_DIR}/files/config-${V_PKG}.sh" + +pbuild::pre_prep() { + curl -fsSLo "$PMODULES_DISTFILESDIR/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" \ + "https://repo.anaconda.com/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" } pbuild::configure() { @@ -18,10 +18,7 @@ pbuild::compile() { } pbuild::install() { - source "${BUILDBLOCK_DIR}/files/config-$V.sh" - - mkdir -p $PREFIX - # Install conda - bash "$SRC_DIR/miniconda.sh" -b -p $PREFIX/conda + bash "$PMODULES_DISTFILESDIR/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh" \ + -b -p "$PREFIX/conda" } diff --git a/Programming/anaconda/files/config-2018.12.sh b/Programming/anaconda/files/config-2018.12.sh index f1ba9d1..db97718 100644 --- a/Programming/anaconda/files/config-2018.12.sh +++ b/Programming/anaconda/files/config-2018.12.sh @@ -4,6 +4,3 @@ # Should match the version distributed with anaconda CONDA_VERSION=4.5.12 -# List of python versions to install -PYTHON_VERSIONS=(2.7) - diff --git a/Programming/anaconda/modulefile b/Programming/anaconda/modulefile index e9e240f..6085ca9 100644 --- a/Programming/anaconda/modulefile +++ b/Programming/anaconda/modulefile @@ -1,18 +1,30 @@ -#%Module +#%Module1.0 -module-whatis "Anaconda software distribution and conda package manager" +module-whatis "Conda package manager and Anaconda software distribution" module-url "https://www.anaconda.com/" module-license "3-clause BSD License and 3rd party software licenses. https://docs.continuum.io/anaconda/eula/" module-maintainer "Spencer Bliven " module-help " -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. +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 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. +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. +This package provides the conda command (miniconda), as well as releases of the +Anaconda distribution, built against several python versions. " set dont-setenv { LD_LIBRARY_PATH } @@ -29,12 +41,18 @@ switch -- $shelltype { switch [module-info mode] { "load" { + #TODO check whether another conda version is present (conflicts) + + puts stderr "Using conda from $P/$V\n" puts stdout "source \"$PREFIX/conda/etc/profile.d/conda.sh\";\n" + + # Activate base + puts stdout "conda activate;\n" } "unload" - "remove" { # Deactivate - puts stderr "which deactivate && source deactivate || source $PREFIX/conda/bin/deactivate;\n" + puts stdout {while [[ "${CONDA_SHLVL:-0}" -gt 0 ]]; do conda deactivate; done;} # Unload conda puts stdout {unset $(set|sed -rn 's/^(_?conda[a-z_]*).*$/\1/pI');}