summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-11-03 18:02:00 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-11-03 18:02:00 +0200
commit12441775f508991deef6aa18de56abf2d743955d (patch)
tree06ad5727df4f3796952d1a7aaefe955fbd20610b
parenteabe86860eb4992fa75d599deec3040009275b01 (diff)
find_python.sh: search in more paths (python, /usr/bin/python etc.)
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
-rwxr-xr-xscripts/find_python.sh51
1 files changed, 19 insertions, 32 deletions
diff --git a/scripts/find_python.sh b/scripts/find_python.sh
index 4a3452cb..12b173be 100755
--- a/scripts/find_python.sh
+++ b/scripts/find_python.sh
@@ -4,31 +4,21 @@ set +e
# function finds python2
function find_python2 {
- # two candidates - machine python and cisco linux python
if [ -n "$PYTHON" ]; then #
return;
fi
-
-
- MACHINE_PYTHON=python
- CEL_PYTHON=/router/bin/python-2.7.4
- # try the machine python
- PYTHON=$MACHINE_PYTHON
- PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)" > /dev/null 2>&1 `
- if [ $? -eq 0 ]; then
- return
- fi
-
- # try the CEL python
- PYTHON=$CEL_PYTHON
- PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)" > /dev/null 2>&1 `
- if [ $? -eq 0 ]; then
- return
- fi
+ # try different Python paths
+ PYTHONS=( python /usr/bin/python /router/bin/python-2.7.4 )
+ for PYTHON in ${PYTHONS[*]}; do
+ $PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)" > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ return
+ fi
+ done;
- echo "*** $MACHINE_PYTHON - python version is too old, 2.7 at least is required"
+ echo "*** Python version is too old, 2.7 at least is required"
exit -1
}
@@ -40,19 +30,16 @@ function find_python3 {
return;
fi
- 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 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 and ver != 35)" > /dev/null 2>&1 `
- if [ $? -eq 0 ]; then
- return
- fi
- echo "*** $MACHINE_PYTHON - python version does not match, 3.4 or 3.5 is required"
+ # try different Python3 paths
+ PYTHONS=( python3 /usr/bin/python3 /auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3 )
+ for PYTHON in ${PYTHONS[*]}; do
+ $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
+ done;
+
+ echo "*** Python3 version does not match, 3.4 or 3.5 is required"
exit -1
}