From 0e4bb98c5ff9d2d7e4471036ef361c67122b6d1b Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 10 Feb 2021 14:47:33 +0100 Subject: [PATCH 1/6] Add python version check to bootstrap script --- bootstrap.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index e4b81eb269..0c188aad59 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -25,6 +25,13 @@ CMD_M() shift && echo -e "${BLUE}==> [$msg]${NC}" ${YELLOW}$*${NC} && $* } +PYTHON_REQ() +{ + pyver=$1 + echo -e "${YELLOW}Unsupported Python Version $pyver: ReFrame requires Python >= 3.6${NC}" + exit 1 +} + usage() { echo "Usage: $0 [-h] [+docs] [+pygelf]" @@ -57,7 +64,13 @@ while [ -n "$1" ]; do esac done -pyver=$($python -V | sed -n 's/Python \([0-9]\+\)\.\([0-9]\+\)\..*/\1.\2/p') +pyver=$($python -V 2>&1 | sed -n 's/Python \([0-9]\+\)\.\([0-9]\+\)\..*/\1.\2/p') +pymajver=$(echo $pyver | cut -f 1 -d '.') +pyminver=$(echo $pyver | cut -f 2 -d '.') + +if [ $pymajver -lt 3 ] || [ $pyminver -lt 6 ]; then + PYTHON_REQ $pyver +fi # Check if ensurepip is installed $python -m ensurepip --version &> /dev/null From e57f8e50a3c317bdf6d38c6b5bf0880430d54fdb Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Tue, 16 Feb 2021 10:11:37 +0100 Subject: [PATCH 2/6] Address PR comments --- bootstrap.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 0c188aad59..3321b4651a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -25,13 +25,6 @@ CMD_M() shift && echo -e "${BLUE}==> [$msg]${NC}" ${YELLOW}$*${NC} && $* } -PYTHON_REQ() -{ - pyver=$1 - echo -e "${YELLOW}Unsupported Python Version $pyver: ReFrame requires Python >= 3.6${NC}" - exit 1 -} - usage() { echo "Usage: $0 [-h] [+docs] [+pygelf]" @@ -64,12 +57,13 @@ while [ -n "$1" ]; do esac done -pyver=$($python -V 2>&1 | sed -n 's/Python \([0-9]\+\)\.\([0-9]\+\)\..*/\1.\2/p') -pymajver=$(echo $pyver | cut -f 1 -d '.') -pyminver=$(echo $pyver | cut -f 2 -d '.') -if [ $pymajver -lt 3 ] || [ $pyminver -lt 6 ]; then - PYTHON_REQ $pyver +# We need to exit with a zero code if the Python version is the correct +# one, so we invert the comparison + +if $python -c 'import sys;sys.exit(sys.version_info[:2] > (3, 6))'; then + echo -e "ReFrame requires Python >= 3.6" + exit 1 fi # Check if ensurepip is installed @@ -81,7 +75,7 @@ if [ $? -eq 0 ]; then fi # ensurepip installs pip in `external/usr/` whereas the --target option installs -# everything under `external/`. That's why include both in the PYTHONPATH +# everything under `external/`. That's we why include both in the PYTHONPATH export PATH=$(pwd)/external/usr/bin:$PATH export PYTHONPATH=$(pwd)/external:$(pwd)/external/usr/lib/python$pyver/site-packages:$PYTHONPATH From 31eeaf9c7bf5efaad324c1b485f65548b13d9085 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Tue, 16 Feb 2021 10:13:00 +0100 Subject: [PATCH 3/6] Fix boostrap script comment --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 3321b4651a..3dd79806fd 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -75,7 +75,7 @@ if [ $? -eq 0 ]; then fi # ensurepip installs pip in `external/usr/` whereas the --target option installs -# everything under `external/`. That's we why include both in the PYTHONPATH +# everything under `external/`. That's why we include both in the PYTHONPATH export PATH=$(pwd)/external/usr/bin:$PATH export PYTHONPATH=$(pwd)/external:$(pwd)/external/usr/lib/python$pyver/site-packages:$PYTHONPATH From 583c0a8cd8cfb1727b67dd565f5bf5694d704c06 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Tue, 16 Feb 2021 10:15:42 +0100 Subject: [PATCH 4/6] Accept also Python 3.6 in boostrapt script --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 3dd79806fd..96f3fdc782 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -61,7 +61,7 @@ done # We need to exit with a zero code if the Python version is the correct # one, so we invert the comparison -if $python -c 'import sys;sys.exit(sys.version_info[:2] > (3, 6))'; then +if $python -c 'import sys;sys.exit(sys.version_info[:2] >= (3, 6))'; then echo -e "ReFrame requires Python >= 3.6" exit 1 fi From 376f39717f6f8021ba3bdc304b55dcabb420a0a0 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Tue, 16 Feb 2021 14:24:49 +0100 Subject: [PATCH 5/6] Improve error message --- bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 96f3fdc782..d962620db9 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -61,8 +61,8 @@ done # We need to exit with a zero code if the Python version is the correct # one, so we invert the comparison -if $python -c 'import sys;sys.exit(sys.version_info[:2] >= (3, 6))'; then - echo -e "ReFrame requires Python >= 3.6" +if $python -c 'import sys; sys.exit(sys.version_info[:2] >= (3, 6))'; then + echo -e "ReFrame requires Python >= 3.6 (found $($python -V 2>&1))" exit 1 fi From 28602f7dd1fbb78a1c93bf7e2071fa2c6a531802 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Tue, 16 Feb 2021 15:37:56 +0100 Subject: [PATCH 6/6] Revert removal of pyver line --- bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap.sh b/bootstrap.sh index 96f3fdc782..c730d84752 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -57,6 +57,7 @@ while [ -n "$1" ]; do esac done +pyver=$($python -V | sed -n 's/Python \([0-9]\+\)\.\([0-9]\+\)\..*/\1.\2/p') # We need to exit with a zero code if the Python version is the correct # one, so we invert the comparison