From d8238aaf862a55eec77040844c71a02c71294e86 Mon Sep 17 00:00:00 2001 From: Zhijux Fan Date: Fri, 28 Dec 2018 15:14:49 +0800 Subject: [PATCH 1/1] BaseTools:Linux Python highest version check. Linux Python highest version check. The path of Python interpreter assign values to PYTHON_COMMAND Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan Tested-by: Laszlo Ersek Tested-by: Ard Biesheuvel Reviewed-by: Liming Gao Reviewed-by: Bob Feng --- edksetup.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/edksetup.sh b/edksetup.sh index 06f95f4b9c..bfa54ddf70 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -115,11 +115,14 @@ function SetupPython() { if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ] then - for python in $(which python3) + if [ $origin_version ];then + origin_version= + fi + for python in $(whereis python3) do python=$(echo $python | grep "[[:digit:]]$" || true) python_version=${python##*python} - if [ -z "${python_version}" ];then + if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then continue fi if [ -z $origin_version ];then @@ -137,14 +140,17 @@ function SetupPython() if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ] then - for python in $(which python2) + if [ $origin_version ];then + origin_version= + fi + for python in $(whereis python2) do python=$(echo $python | grep "[[:digit:]]$" || true) python_version=${python##*python} - if [ -z "${python_version}" ];then + if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then continue fi - if [ -z $origin_version ] || [ $origin_version -ge 3 ] + if [ -z $origin_version ] then origin_version=$python_version export PYTHON=$python -- 2.39.2