From: Zhijux Fan <zhijux....@intel.com>

Linux Python highest version check.
The path of Python interpreter assign values to PYTHON_COMMAND

Cc: Bob Feng <bob.c.f...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux....@intel.com>
---
 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
@@ -113,15 +113,18 @@ function SetupEnv()
 
 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
         origin_version=$python_version
         export PYTHON=$python
@@ -135,18 +138,21 @@ function SetupPython()
     done
   fi
   
   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
         continue
       fi
-- 
2.20.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to