Skip to content

Commit 5780431

Browse files
authored
Merge pull request #15654 from rmcdermo/master
Python: fix check of python version
2 parents 5905c08 + 04a90ec commit 5780431

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Utilities/Python/setup_python_env.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ function error_exit {
2424

2525

2626
# Check Python version > 3.7
27-
PYTHON_VERSION=$(python3 -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
28-
REQUIRED_VERSION=3.7
29-
if (( $(echo "$PYTHON_VERSION < $REQUIRED_VERSION" | bc -l) )); then
30-
echo "Python 3.7 or higher is required. Found $PYTHON_VERSION."
27+
major=$(python3 -c 'import sys; print(sys.version_info.major)')
28+
minor=$(python3 -c 'import sys; print(sys.version_info.minor)')
29+
30+
if (( major < 3 || (major == 3 && minor < 7) )); then
31+
echo "Python 3.7 or higher is required. Found $major.$minor."
3132
echo "Stopping python environment setup."
3233
return
3334
else
34-
echo "Python version is OK: $PYTHON_VERSION"
35+
echo "Python version is OK: $major.$minor"
3536
fi
3637

38+
3739
# Save current directory to return later
3840
curdir=$(pwd)
3941

0 commit comments

Comments
 (0)