Skip to content
Snippets Groups Projects
Commit fea28292 authored by Oriol Tintó Prims's avatar Oriol Tintó Prims
Browse files

Adapt build_python_environment.sh to use the new spack_utils.sh functions.

parent ba3ea1bb
No related branches found
No related tags found
1 merge request!4Switching to the advanced configuration method and fixing spack build.
......@@ -6,33 +6,20 @@ SPACK_URL=%spack.url%
SPACK_BRANCH=%spack.branch%
SPACK_COMPILER=%spack.compiler%
# If the workdir directory does not exist create it
if [ ! -d ${WORKDIR} ]; then
mkdir -p ${WORKDIR}
fi
# Go to the working directory
cd ${WORKDIR}
# Check if experiment's spack installation already exists, if it doesn't, clone it.
SPACK_ENV=spack/share/spack/setup-env.sh
if [ ! -f ${SPACK_ENV} ]; then
echo "Spack folder not found!"
exit 1
fi
. ${WORKDIR}/proj/platforms/common/spack_utils.sh
load_spack "%spack.init%" "%spack.root%" "%spack.url%" "%spack.branch%" "%spack.compiler%" "%spack.disable_local_config%" "%spack.user_cache_path%" "%spack.user_config_path%"
# Setup the spack environment
source ${SPACK_ENV}
# Use spack to get a recent enough version of python3
if [ $( spack find python@3.8: &>/dev/null
echo $?
) -ne 0 ]; then
if [ $(spack find python@3.8: &>/dev/null ) ]; then
echo "python@3.8: already installed!"
else
echo "Installing a version of python3"
# Compile openmpi with schedulers=slurm
spack install python@3.8:
else
echo "python@3.8: already installed!"
fi
# Load the python module
......@@ -56,7 +43,7 @@ ln -sf $(which python3) ${WORKDIR}/python3
requirements="%python_environment.requirements%"
# Convert list with python format to a bash array
requirements=($( echo ${requirements} | sed "s/'//g" | tr -d '[],'))
requirements=($(echo ${requirements} | sed "s/'//g" | tr -d '[],'))
#TODO: Shouldn't be necessary but it is for now to overcome an issue with a repetition of the requirements.
# Use sort and uniq to get the unique elements
......@@ -66,6 +53,6 @@ unique_requirements=($(printf "%s\n" "${requirements[@]}" | sort -u))
echo "${unique_requirements[@]}"
# Install requirements.
for requirement in ${unique_requirements[@]} ; do
for requirement in "${unique_requirements[@]}"; do
python -m pip install ${requirement}
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment