summaryrefslogtreecommitdiffstats
path: root/scripts/find_python.sh
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-09-28 12:23:17 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-09-28 12:23:17 +0300
commit08aaabafd6a07491bb89324c1306e6e88ae46980 (patch)
treed3367213b02aa69db2f3fe54d62f283262d3ab86 /scripts/find_python.sh
parentffff2512ebbd65773a784565ce78d51d2ceb9a8d (diff)
find_python.sh by default find any available Python, allow 3.5 too.
t-rex-64 fix case of no $USER when not in tty
Diffstat (limited to 'scripts/find_python.sh')
-rwxr-xr-xscripts/find_python.sh15
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/find_python.sh b/scripts/find_python.sh
index 9a9717c1..ea3c6b35 100755
--- a/scripts/find_python.sh
+++ b/scripts/find_python.sh
@@ -26,7 +26,7 @@ function find_python2 {
return
fi
- echo "*** $PYTHON - python version is too old, 2.7 at least is required"
+ echo "*** $MACHINE_PYTHON - python version is too old, 2.7 at least is required"
exit -1
}
@@ -41,16 +41,16 @@ function find_python3 {
MACHINE_PYTHON=python3
ITAY_PYTHON=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3
PYTHON=$MACHINE_PYTHON
- PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)" > /dev/null 2>&1 `
+ PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 `
if [ $? -eq 0 ]; then
return
fi
PYTHON=$ITAY_PYTHON
- PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)" > /dev/null 2>&1 `
+ PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 `
if [ $? -eq 0 ]; then
return
fi
- echo "*** $PYTHON - python version does not match, 3.4 is required"
+ echo "*** $MACHINE_PYTHON - python version does not match, 3.4 or 3.5 is required"
exit -1
}
@@ -74,8 +74,11 @@ case "$1" in
;;
esac
;;
- *) # default is python2
- find_python2
+ *) # default is find any
+ (find_python2) &> /dev/null && find_python2 && return
+ (find_python3) &> /dev/null && find_python3 && return
+ echo "Python versions 2.7 or 3.4 or 3.5 required"
+ exit -1
;;
esac
fi