Skip to content

Instantly share code, notes, and snippets.

@mmterpstra
Last active April 11, 2023 13:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmterpstra/d11ec81bf78c169ab6be5911df384496 to your computer and use it in GitHub Desktop.
Save mmterpstra/d11ec81bf78c169ab6be5911df384496 to your computer and use it in GitHub Desktop.
Easybuild below easybuild

installing

These are the steps:

#1. create and goto dir
mkdir path/to/apps/
cd path/to/apps/

wget https://gist.githubusercontent.com/mmterpstra/d11ec81bf78c169ab6be5911df384496/raw/easybuild_profile -O easybuild_profile
perl -i.bak -wpe 's/HPC_ENV_MYPREFIX/HPC_ENV_'$USER'/g' easybuild_profile 
. ./easybuild_profile &>/dev/null

# Install easybuild EasyBuild (https://docs.easybuild.io/en/latest/Installation.html)
# the $HPC_ENV_PREFIX is set to `path/to/apps/` or whatever you put the `easybuild_profile` in.

(ml EasyBuild && eb --install-latest-eb-release --prefix HPC_ENV_MYPREFIX)

#3. update your module references

. ./easybuild_profile

#4. install easybuild files

Run at login

Add this to your bash profile editing the ebbase="path/to/apps/"

ebbase="path/to/apps/"
if [ ${TERM} != 'dumb' ] ; then
	#private easybuild. "Keepin things easy"
	ebprofile=$ebbase"easybuild_profile"
	if [ -f $ebprofile ]; then
	        echo "## "$(date)" ##src ebprofile" &>/dev/stderr
	        . $ebprofile
	fi
else
        ebprofile=$ebbase"easybuild_profile"
        if [ -f $ebprofile ]; then
                . $ebprofile &>/dev/null
        fi
fi
#
##
### Check if we need to be sourced.
##
#
# Make sure we do not source this file for SFTP connections, << invalid you can source anything if it does not return any text without preceeding '#'
# which will terminate instantly when anything that is not a valid FTP command
# is printed on STDOUT or STDERR.
# For SFTP connections as well as SLURM jobs the TERM type is dumb,
# but in the first case there are no SLURM related environment variables defined.
#if [ ${TERM} == 'dumb' ] && [[ ! "${BASH_EXECUTION_STRING}" =~ 'slurm' ]] && [ -z ${SLURM_JOBID} ] && [ -z ${HPC_ENV_SYNC_BY_CRON} ]; then
# return
#fi
#LMOD=/usr/share/lmod/lmod/libexec/lmod
#upper works most of the time here is the lazyer config
LMOD="$(which lmod)"
if [ -e $LMOD ] ; then
export PATH=$PATH":"$(dirname $LMOD)
else
echo "lmod not found in $LMOD"
exit 1
fi
#
##
### Update HPC environment.
##
#
#echo "BASH_SRC="${BASH_SOURCE[0]}" 0="$0
MY_DIR=$(cd -P $( dirname "${BASH_SOURCE[0]}" ) && pwd)
#echo $MY_DIR
export HPC_ENV_MYPREFIX=${MY_DIR}
#echo -n "Fetching available environment modules from ${HPC_ENV_PREFIX}/modules/... "
#
# EasyBuild env vars.
#
export EASYBUILD_MODULES_TOOL='Lmod'
export EASYBUILD_INSTALLPATH="${HPC_ENV_MYPREFIX}"
export EASYBUILD_BUILDPATH="${HPC_ENV_MYPREFIX}/.tmp/easybuild/builds/${USER}/"
export EASYBUILD_SOURCEPATH="${HPC_ENV_MYPREFIX}/sources/"
#export TEST_EASYBUILD_MODULES_TOOL='Lmod'
#
# Configure our module tool (Lmod).
#
export PATH="/usr/share/lmod/lmod/libexec/:${PATH}"
export LMOD_CACHE_DIR="${HPC_ENV_MYPREFIX}/modules/.lmod/cache/"
export LMOD_TIMESTAMP_FILE="${HPC_ENV_MYPREFIX}/modules/.lmod/modules_changed.timestamp"
export LMOD_RC="${HPC_ENV_MYPREFIX}/modules/.lmod/lmodrc.lua"
export LMOD_ADMIN_FILE="${HPC_ENV_MYPREFIX}/modules/modules.admin"
export LMOD_CASE_INDEPENDENT_SORTING='True'
export LMOD_REDIRECT='True'
export LMOD_PAGER='none'
mod_classes=""
for module_class in $(ls -1 ${HPC_ENV_MYPREFIX}/modules/ ); do
if [ "${module_class}" != 'all' ] && \
[ -d ${HPC_ENV_MYPREFIX}/modules/${module_class}/ ] && \
[ -r ${HPC_ENV_MYPREFIX}/modules/${module_class}/ ]; then
mod_classes="${mod_classes} ${HPC_ENV_MYPREFIX}/modules/${module_class}/"
fi
done
module -q use ${mod_classes}
#echo 'done!'
set -e -x -o pipefail
#cannnot get this to work on version 2.6!
python -c '#!/usr/bin/env python
import sys
if sys.version_info[0] != 2 or sys.version_info[1] < 7:
print("This script requires Python version 2.7 or ml Python/2.7.11-foss-2015b")
sys.exit(1)'
dir=$(dirname $(which $0 2> /dev/null) 2>/dev/null || readlink -f $(dirname $0))
#1. create and goto dir
#mkdir -p $dir
cd $dir
#just latest and the greatest
wget https://gist.githubusercontent.com/mmterpstra/d11ec81bf78c169ab6be5911df384496/easybuild_profile
#this might cause errors due to the fact that some subdirs aren't set up by easybuild that's why the error checking is turned on and off
set +e +x
. ./easybuild_profile
set -e -x -o pipefail
#2. download and install latest and greatest easybuild
# the $HPC_ENV_MYPREFIX is set to `path/to/apps/` or whatever dir you put the `easybuild_profile` in.
#export EASYBUILD_ENFORCE_CHECKSUMS=False
(ml EasyBuild && eb --install-latest-eb-release --prefix $HPC_ENV_MYPREFIX)
#export EASYBUILD_ENFORCE_CHECKSUMS=True
#3. update your module references
. ./easybuild_profile
ml --ignore-cache av
echo "## Done!!!!"
echo "#ps if you don't want to source it everytime you still need to add the piece of code in the readme to your ~/.bashrc."
#4. install easybuild files
@dennishendriksen
Copy link

dennishendriksen commented Feb 25, 2020

lmod not found found it in /apps/software/lmod/lmod/libexec/lmod and EASYBUILD_ENFORCE_CHECKSUMS=True not checked

@mmterpstra
Copy link
Author

Updated now it should work on your usecase!

@dennishendriksen
Copy link

Thanks

@mmterpstra
Copy link
Author

mmterpstra commented Feb 11, 2022

Updated to work again due to bootstrap.py no longer being allowed. might need some testing though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment