Skip to content

Commit 58c1da5

Browse files
committed
adding changes from PR EESSI#812 to validate them here
1 parent 7cead8e commit 58c1da5

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

EESSI-install-software.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,14 @@ unset EESSI_PROJECT_INSTALL
273273
unset EESSI_SITE_INSTALL
274274
export EESSI_CVMFS_INSTALL=1
275275
module unload EESSI-extend
276-
module load EESSI-extend/${EESSI_VERSION}-easybuild
276+
277+
# The EESSI-extend module is being loaded (or installed if it doesn't exist yet).
278+
# The script requires the EESSI_VERSION given as argument, a couple of
279+
# environment variables set (TMPDIR, EB and EASYBUILD_INSTALLPATH) and the
280+
# function check_exit_code defined.
281+
# NOTE, the script exits if those variables/functions are undefined.
282+
export EASYBUILD_INSTALLPATH=${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
283+
source load_eessi_extend_module.sh ${EESSI_VERSION}
277284

278285
if [ ! -z "${shared_fs_path}" ]; then
279286
shared_eb_sourcepath=${shared_fs_path}/easybuild/sources

load_eessi_extend_module.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Script to load the environment module for EESSI-extend.
2+
# If that module is not available yet, a specific version will be installed using the latest EasyBuild.
3+
#
4+
# This script must be sourced, since it makes changes in the current environment, like loading an EESSI-extend module.
5+
#
6+
# Assumptions (if one is not satisfied the script prints a message and exits)
7+
# - EESSI version is given as first argument
8+
# - TMPDIR is set
9+
# - EB is set
10+
# - EASYBUILD_INSTALLPATH needs to be set
11+
# - Function check_exit_code is defined;
12+
# scripts/utils.sh in EESSI/software-layer repository defines this function, hence
13+
# scripts/utils.sh shall be sourced before this script is run
14+
#
15+
# This script is part of the EESSI software layer, see
16+
# https://github.com/EESSI/software-layer.git
17+
#
18+
# author: Kenneth Hoste (@boegel, HPC-UGent)
19+
# author: Alan O'Cais (@ocaisa, CECAM)
20+
# author: Thomas Roeblitz (@trz42, University of Bergen)
21+
#
22+
# license: GPLv2
23+
#
24+
#
25+
set -o pipefail
26+
27+
# this script is *sourced*, not executed, so can't rely on $0 to determine path to self or script name
28+
# $BASH_SOURCE points to correct path or script name, see also http://mywiki.wooledge.org/BashFAQ/028
29+
if [ $# -ne 1 ]; then
30+
echo "Usage: source ${BASH_SOURCE} <EESSI-extend version>" >&2
31+
exit 1
32+
fi
33+
34+
EESSI_EXTEND_VERSION="${1}-easybuild"
35+
36+
# make sure that environment variables that we expect to be set are indeed set
37+
if [ -z "${TMPDIR}" ]; then
38+
echo "\$TMPDIR is not set; exiting" >&2
39+
exit 2
40+
fi
41+
42+
# ${EB} is used to specify which 'eb' command should be used;
43+
# can potentially be more than just 'eb', for example when using 'eb --optarch=GENERIC'
44+
if [ -z "${EB}" ]; then
45+
echo "\$EB is not set; exiting" >&2
46+
exit 2
47+
fi
48+
49+
# ${EASYBUILD_INSTALLPATH} points to the installation path and needs to be set
50+
if [ -z "${EASYBUILD_INSTALLPATH}" ]; then
51+
echo "\$EASYBUILD_INSTALLPATH is not set; exiting" >&2
52+
exit 2
53+
fi
54+
55+
# make sure that utility functions are defined (cfr. scripts/utils.sh script in EESSI/software-layer repo)
56+
type check_exit_code
57+
if [ $? -ne 0 ]; then
58+
echo "check_exit_code function is not defined; exiting" >&2
59+
exit 3
60+
fi
61+
62+
echo ">> Checking for EESSI-extend module..."
63+
64+
ml_av_eessi_extend_out=${TMPDIR}/ml_av_eessi_extend.out
65+
module avail 2>&1 | grep -i EESSI-extend/${EESSI_EXTEND_VERSION} &> ${ml_av_eessi_extend_out}
66+
67+
if [[ $? -eq 0 ]]; then
68+
echo_green ">> Module for EESSI-extend/${EESSI_EXTEND_VERSION} found!"
69+
else
70+
echo_yellow ">> No module yet for EESSI-extend/${EESSI_EXTEND_VERSION}, installing it..."
71+
72+
EB_TMPDIR=${TMPDIR}/ebtmp
73+
echo ">> Using temporary installation of EasyBuild (in ${EB_TMPDIR})..."
74+
pip_install_out=${TMPDIR}/pip_install.out
75+
pip3 install --prefix ${EB_TMPDIR} easybuild &> ${pip_install_out}
76+
77+
# keep track of original $PATH and $PYTHONPATH values, so we can restore them
78+
ORIG_PATH=${PATH}
79+
ORIG_PYTHONPATH=${PYTHONPATH}
80+
81+
echo ">> Final installation in ${EASYBUILD_INSTALLPATH}..."
82+
export PATH=${EB_TMPDIR}/bin:${PATH}
83+
export PYTHONPATH=$(ls -d ${EB_TMPDIR}/lib/python*/site-packages):${PYTHONPATH}
84+
eb_install_out=${TMPDIR}/eb_install.out
85+
ok_msg="EESSI-extend/${EESSI_EXTEND_VERSION} installed, let's go!"
86+
fail_msg="Installing EESSI-extend/${EESSI_EXTEND_VERSION} failed, that's not good... (output: ${eb_install_out})"
87+
${EB} "EESSI-extend-${EESSI_EXTEND_VERSION}.eb" 2>&1 | tee ${eb_install_out}
88+
check_exit_code $? "${ok_msg}" "${fail_msg}"
89+
90+
# restore origin $PATH and $PYTHONPATH values, and clean up environment variables that are no longer needed
91+
export PATH=${ORIG_PATH}
92+
export PYTHONPATH=${ORIG_PYTHONPATH}
93+
unset EB_TMPDIR ORIG_PATH ORIG_PYTHONPATH
94+
95+
module --ignore-cache avail EESSI-extend/${EESSI_EXTEND_VERSION} &> ${ml_av_eessi_extend_out}
96+
if [[ $? -eq 0 ]]; then
97+
echo_green ">> EESSI-extend/${EESSI_EXTEND_VERSION} module installed!"
98+
else
99+
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})"
100+
fi
101+
fi
102+
103+
echo ">> Loading EESSI-extend/${EESSI_EXTEND_VERSION} module..."
104+
module --ignore-cache load EESSI-extend/${EESSI_EXTEND_VERSION}
105+
106+
unset EESSI_EXTEND_VERSION

0 commit comments

Comments
 (0)