BaseTools:Linux Python highest version check.

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

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Zhijux Fan 2018-12-28 15:14:49 +08:00 committed by Feng, Bob C
parent fd2d74007b
commit d8238aaf86
1 changed files with 11 additions and 5 deletions

View File

@ -115,11 +115,14 @@ function SetupPython()
{ {
if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ] if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
then then
for python in $(which python3) if [ $origin_version ];then
origin_version=
fi
for python in $(whereis python3)
do do
python=$(echo $python | grep "[[:digit:]]$" || true) python=$(echo $python | grep "[[:digit:]]$" || true)
python_version=${python##*python} python_version=${python##*python}
if [ -z "${python_version}" ];then if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then
continue continue
fi fi
if [ -z $origin_version ];then if [ -z $origin_version ];then
@ -137,14 +140,17 @@ function SetupPython()
if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ] if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ]
then then
for python in $(which python2) if [ $origin_version ];then
origin_version=
fi
for python in $(whereis python2)
do do
python=$(echo $python | grep "[[:digit:]]$" || true) python=$(echo $python | grep "[[:digit:]]$" || true)
python_version=${python##*python} python_version=${python##*python}
if [ -z "${python_version}" ];then if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then
continue continue
fi fi
if [ -z $origin_version ] || [ $origin_version -ge 3 ] if [ -z $origin_version ]
then then
origin_version=$python_version origin_version=$python_version
export PYTHON=$python export PYTHON=$python