Skip to content

Commit f275169

Browse files
authored
Merge pull request #3998 from boegel/eb_import_check
change 'eb' command to import easybuild.framework to check if EasyBuild framework is available
2 parents ccc1a4d + 50558f9 commit f275169

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.github/workflows/eb_command.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ jobs:
7373
pymajver=$(python -c 'import sys; print(sys.version_info[0])')
7474
pymajminver=$(python -c 'import sys; print(".".join(str(x) for x in sys.version_info[:2]))')
7575
# check patterns in verbose output
76-
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
76+
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
7777
echo "Looking for pattern \"${pattern}\" in eb_version.out..."
7878
grep "$pattern" eb_version.out
7979
done
8080
# also check when specifying Python command via $EB_PYTHON
8181
for eb_python in "python${pymajver}" "python${pymajminver}"; do
8282
export EB_PYTHON="${eb_python}"
8383
eb --version | tee eb_version.out 2>&1
84-
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
84+
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
8585
echo "Looking for pattern \"${pattern}\" in eb_version.out..."
8686
grep "$pattern" eb_version.out
8787
done

eb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ REQ_MIN_PY3VER=5
4646

4747
EASYBUILD_MAIN='easybuild.main'
4848

49+
# easybuild module to import to check whether EasyBuild framework is available;
50+
# don't use easybuild.main here, since that's a very expensive module to import (it makes the 'eb' command slow)
51+
EASYBUILD_IMPORT_TEST='easybuild.framework'
52+
4953
function verbose() {
5054
if [ ! -z ${EB_VERBOSE} ]; then echo ">> $1"; fi
5155
}
@@ -79,13 +83,13 @@ for python_cmd in ${EB_PYTHON} ${EB_INSTALLPYTHON} 'python' 'python3' 'python2';
7983
fi
8084

8185
if [ ! -z $PYTHON ]; then
82-
# check whether easybuild is available for selected python command
83-
$PYTHON -c "import easybuild" 2> /dev/null
86+
# check whether EasyBuild framework is available for selected python command
87+
$PYTHON -c "import $EASYBUILD_IMPORT_TEST" 2> /dev/null
8488
if [ $? -eq 0 ]; then
85-
verbose "'$python_cmd' is able to import 'easybuild', so retaining it"
89+
verbose "'$python_cmd' is able to import '$EASYBUILD_IMPORT_TEST', so retaining it"
8690
else
87-
# if easybuild is not available, don't use this python command, keep searching...
88-
verbose "'$python_cmd' is NOT able to import 'easybuild' so NOT retaining it"
91+
# if EasyBuild framework is not available, don't use this python command, keep searching...
92+
verbose "'$python_cmd' is NOT able to import '$EASYBUILD_IMPORT_TEST' so NOT retaining it"
8993
unset PYTHON
9094
fi
9195
fi

0 commit comments

Comments
 (0)