Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/eb_command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ jobs:
pymajver=$(python -c 'import sys; print(sys.version_info[0])')
pymajminver=$(python -c 'import sys; print(".".join(str(x) for x in sys.version_info[:2]))')
# check patterns in verbose output
for pattern in "^>> Considering .python.\.\.\." "^>> .python. version: ${pymajminver}\.[0-9]\+, which matches Python ${pymajver} version requirement" "^>> 'python' is able to import 'easybuild', so retaining it" "^>> Selected Python command: python \(.*/bin/python\)" "^This is EasyBuild 4\.[0-9.]\+"; do
for pattern in "^>> Considering .python.\.\.\." "^>> .python. version: ${pymajminver}\.[0-9]\+, which matches Python ${pymajver} version requirement" "^>> 'python' is able to import 'easybuild.framework', so retaining it" "^>> Selected Python command: python \(.*/bin/python\)" "^This is EasyBuild 4\.[0-9.]\+"; do
echo "Looking for pattern \"${pattern}\" in eb_version.out..."
grep "$pattern" eb_version.out
done
# also check when specifying Python command via $EB_PYTHON
for eb_python in "python${pymajver}" "python${pymajminver}"; do
export EB_PYTHON="${eb_python}"
eb --version | tee eb_version.out 2>&1
for pattern in "^>> Considering .${eb_python}.\.\.\." "^>> .${eb_python}. version: ${pymajminver}\.[0-9]\+, which matches Python ${pymajver} version requirement" "^>> '${eb_python}' is able to import 'easybuild', so retaining it" "^>> Selected Python command: ${eb_python} \(.*/bin/${eb_python}\)" "^This is EasyBuild 4\.[0-9.]\+"; do
for pattern in "^>> Considering .${eb_python}.\.\.\." "^>> .${eb_python}. version: ${pymajminver}\.[0-9]\+, which matches Python ${pymajver} version requirement" "^>> '${eb_python}' is able to import 'easybuild.framework', so retaining it" "^>> Selected Python command: ${eb_python} \(.*/bin/${eb_python}\)" "^This is EasyBuild 4\.[0-9.]\+"; do
echo "Looking for pattern \"${pattern}\" in eb_version.out..."
grep "$pattern" eb_version.out
done
Expand Down
14 changes: 9 additions & 5 deletions eb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ REQ_MIN_PY3VER=5

EASYBUILD_MAIN='easybuild.main'

# easybuild module to import to check whether EasyBuild framework is available;
# don't use easybuild.main here, since that's a very expensive module to import (it makes the 'eb' command slow)
EASYBUILD_IMPORT_TEST='easybuild.framework'

function verbose() {
if [ ! -z ${EB_VERBOSE} ]; then echo ">> $1"; fi
}
Expand Down Expand Up @@ -79,13 +83,13 @@ for python_cmd in ${EB_PYTHON} ${EB_INSTALLPYTHON} 'python' 'python3' 'python2';
fi

if [ ! -z $PYTHON ]; then
# check whether easybuild is available for selected python command
$PYTHON -c "import easybuild" 2> /dev/null
# check whether EasyBuild framework is available for selected python command
$PYTHON -c "import $EASYBUILD_IMPORT_TEST" 2> /dev/null
if [ $? -eq 0 ]; then
verbose "'$python_cmd' is able to import 'easybuild', so retaining it"
verbose "'$python_cmd' is able to import '$EASYBUILD_IMPORT_TEST', so retaining it"
else
# if easybuild is not available, don't use this python command, keep searching...
verbose "'$python_cmd' is NOT able to import 'easybuild' so NOT retaining it"
# if EasyBuild framework is not available, don't use this python command, keep searching...
verbose "'$python_cmd' is NOT able to import '$EASYBUILD_IMPORT_TEST' so NOT retaining it"
unset PYTHON
fi
fi
Expand Down