From 759a5eeb1794271419e72d241bcbad2bda97ab9c Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Thu, 31 Oct 2024 15:24:09 +0100 Subject: [PATCH 1/2] Add a script that can install EESSI-extend if it doesn't exist --- EESSI-install-software.sh | 5 ++- load_eessi_extend_module.sh | 89 +++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100755 load_eessi_extend_module.sh diff --git a/EESSI-install-software.sh b/EESSI-install-software.sh index 5b684582ce..3e3a5f540b 100755 --- a/EESSI-install-software.sh +++ b/EESSI-install-software.sh @@ -285,9 +285,10 @@ ec=$? if [ ${ec} -eq 0 ]; then module load ${eessi_extend_module} else - echo "Did not find ${eessi_extend_module} module; setting EASYBUILD_INSTALLPATH and EASYBUILD_EXPERIMENTAL manually" + echo "Did not find ${eessi_extend_module} module; installing it with latest EasyBuild" + # EESSI-extend is the thing that sets EASYBUILD_INSTALLPATH so we have a chicken/egg situation to resolve export EASYBUILD_INSTALLPATH=${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE} - export EASYBUILD_EXPERIMENTAL=1 + source load_eessi_extend_module.sh ${EESSI_VERSION} fi if [ ! -z "${shared_fs_path}" ]; then diff --git a/load_eessi_extend_module.sh b/load_eessi_extend_module.sh new file mode 100755 index 0000000000..ffac49eedb --- /dev/null +++ b/load_eessi_extend_module.sh @@ -0,0 +1,89 @@ +# Script to load the environment module for a specific version of EasyBuild. +# If that module is not available yet, the current latest EasyBuild version of EasyBuild will be installed, +# and used to install the specific EasyBuild version being specified. +# +# This script must be sourced, since it makes changes in the current environment, like loading an EasyBuild module. +# +# This script is part of the EESSI software layer, see +# https://github.com/EESSI/software-layer.git +# +# author: Kenneth Hoste (@boegel, HPC-UGent) +# author: Alan O'Cais (@ocaisa, CECAM) +# +# license: GPLv2 +# +# +set -o pipefail + +if [ $# -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +EESSI_EXTEND_VERSION="${1}-easybuild" + +# make sure that environment variables that we expect to be set are indeed set +if [ -z "${TMPDIR}" ]; then + echo "\$TMPDIR is not set" >&2 + exit 2 +fi + +# ${EB} is used to specify which 'eb' command should be used; +# can potentially be more than just 'eb', for example when using 'eb --optarch=GENERIC' +if [ -z "${EB}" ]; then + echo "\$EB is not set" >&2 + exit 2 +fi + +# make sure that utility functions are defined (cfr. scripts/utils.sh script in EESSI/software-layer repo) +type check_exit_code +if [ $? -ne 0 ]; then + echo "check_exit_code function is not defined" >&2 + exit 3 +fi + +echo ">> Checking for EESSI-extend module..." + +ml_av_eessi_extend_out=${TMPDIR}/ml_av_eessi_extend.out +module avail 2>&1 | grep -i EESSI-extend/${EESSI_EXTEND_VERSION} &> ${ml_av_eessi_extend_out} + +if [[ $? -eq 0 ]]; then + echo_green ">> Module for EESSI-extend/${EESSI_EXTEND_VERSION} found!" +else + echo_yellow ">> No module yet for EESSI-extend/${EESSI_EXTEND_VERSION}, installing it..." + + EB_TMPDIR=${TMPDIR}/ebtmp + echo ">> Using temporary installation of EasyBuild (in ${EB_TMPDIR})..." + pip_install_out=${TMPDIR}/pip_install.out + pip3 install --prefix ${EB_TMPDIR} easybuild &> ${pip_install_out} + + # keep track of original $PATH and $PYTHONPATH values, so we can restore them + ORIG_PATH=${PATH} + ORIG_PYTHONPATH=${PYTHONPATH} + + echo ">> Final installation in ${EASYBUILD_INSTALLPATH}..." + export PATH=${EB_TMPDIR}/bin:${PATH} + export PYTHONPATH=$(ls -d ${EB_TMPDIR}/lib/python*/site-packages):${PYTHONPATH} + eb_install_out=${TMPDIR}/eb_install.out + ok_msg="EESSI-extend/${EESSI_EXTEND_VERSION} installed, let's go!" + fail_msg="Installing EESSI-extend/${EESSI_EXTEND_VERSION} failed, that's not good... (output: ${eb_install_out})" + ${EB} "EESSI-extend-${EESSI_EXTEND_VERSION}.eb" 2>&1 | tee ${eb_install_out} + check_exit_code $? "${ok_msg}" "${fail_msg}" + + # restore origin $PATH and $PYTHONPATH values, and clean up environment variables that are no longer needed + export PATH=${ORIG_PATH} + export PYTHONPATH=${ORIG_PYTHONPATH} + unset EB_TMPDIR ORIG_PATH ORIG_PYTHONPATH + + module --ignore-cache avail EESSI-extend/${EESSI_EXTEND_VERSION} &> ${ml_av_eessi_extend_out} + if [[ $? -eq 0 ]]; then + echo_green ">> EESSI-extend/${EESSI_EXTEND_VERSION} module installed!" + else + fatal_error "EESSI-extend/${EESSI_EXTEND_VERSION} module failed to install?! (output of 'pip install' in ${pip_install_out}, output of 'eb' in ${eb_install_out}, output of 'module avail EESSI-extend' in ${ml_av_eessi_extend_out})" + fi +fi + +echo ">> Loading EESSI-extend/${EESSI_EXTEND_VERSION} module..." +module --ignore-cache load EESSI-extend/${EESSI_EXTEND_VERSION} + +unset EESSI_EXTEND_VERSION From 636bcfba65a025a48415bf6474f870181230a0f8 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Thu, 31 Oct 2024 15:26:50 +0100 Subject: [PATCH 2/2] Tidy up comments --- load_eessi_extend_module.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/load_eessi_extend_module.sh b/load_eessi_extend_module.sh index ffac49eedb..95101f8d0c 100755 --- a/load_eessi_extend_module.sh +++ b/load_eessi_extend_module.sh @@ -1,8 +1,7 @@ -# Script to load the environment module for a specific version of EasyBuild. -# If that module is not available yet, the current latest EasyBuild version of EasyBuild will be installed, -# and used to install the specific EasyBuild version being specified. +# Script to load the environment module for EESSI-extend. +# If that module is not available yet, a specific version will be installed using the latest EasyBuild. # -# This script must be sourced, since it makes changes in the current environment, like loading an EasyBuild module. +# This script must be sourced, since it makes changes in the current environment, like loading an EESSI-extend module. # # This script is part of the EESSI software layer, see # https://github.com/EESSI/software-layer.git