Update PYTHON env to PYTHON_COMMAND.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
- python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
fi
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
@setlocal\r
@set ToolName=%~n0%\r
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python\r
-@%PYTHON% -m %ToolName%.%ToolName% %*\r
+@%PYTHON_COMMAND% -m %ToolName%.%ToolName% %*\r
@setlocal\r
@set ToolName=%~n0%\r
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python\r
-@%PYTHON% -m %ToolName%.EccMain %*\r
+@%PYTHON_COMMAND% -m %ToolName%.EccMain %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python\r
-@%PYTHON% -m %ToolName%.%ToolName% %*\r
+@%PYTHON_COMMAND% -m %ToolName%.%ToolName% %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
all: c\r
\r
c :\r
- @$(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C\r
\r
\r
subdirs: $(SUBDIRS)\r
- @$(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $**\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $**\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $**\r
\r
.PHONY: clean\r
clean:\r
- $(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)\r
\r
.PHONY: cleanall\r
cleanall:\r
- $(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)\r
\r
@echo # Build libraries\r
@echo ######################\r
@if not exist $(LIB_PATH) mkdir $(LIB_PATH)\r
- @$(PYTHON) Makefiles\NmakeSubdirs.py all $**\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py all $**\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py all $**\r
\r
apps: $(APPLICATIONS)\r
@echo.\r
@echo # Build executables\r
@echo ######################\r
@if not exist $(BIN_PATH) mkdir $(BIN_PATH)\r
- @$(PYTHON) Makefiles\NmakeSubdirs.py all $**\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py all $**\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py all $**\r
\r
install: $(LIB_PATH) $(BIN_PATH)\r
@echo.\r
\r
.PHONY: clean\r
clean:\r
- @$(PYTHON) Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)\r
\r
.PHONY: cleanall\r
cleanall:\r
- @$(PYTHON) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)\r
+ @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)\r
+ @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)\r
\r
!INCLUDE Makefiles\ms.rule\r
\r
if PYTHON3_ENABLE != "TRUE":\r
PYTHON3_ENABLE = "FALSE"\r
EdkLogger.quiet("%-16s = %s" % ("PYTHON3_ENABLE", PYTHON3_ENABLE))\r
- EdkLogger.quiet("%-16s = %s" % ("PYTHON", os.environ["PYTHON"]))\r
+ if "PYTHON_COMMAND" in os.environ:\r
+ EdkLogger.quiet("%-16s = %s" % ("PYTHON_COMMAND", os.environ["PYTHON_COMMAND"]))\r
self.InitPreBuild()\r
self.InitPostBuild()\r
if self.Prebuild:\r
all: test\r
\r
test:\r
- @if command -v $(PYTHON) >/dev/null 1; then $(PYTHON) RunTests.py; else python RunTests.py; fi\r
+ @if command -v $(PYTHON_COMMAND) >/dev/null 1; then $(PYTHON_COMMAND) RunTests.py; else python RunTests.py; fi\r
\r
clean:\r
find . -name '*.pyc' -exec rm '{}' ';'\r
--- /dev/null
+## @file\r
+# Test whether PYTHON_COMMAND is available\r
+#\r
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+\r
+if __name__ == '__main__':\r
+ print('TRUE')\r
)\r
\r
:defined_python\r
+if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
+ goto check_python_available\r
+)\r
if defined PYTHON3_ENABLE (\r
if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
- set PYTHON=py -3\r
- %PYTHON% --version >NUL 2>&1\r
- if %ERRORLEVEL% NEQ 0 (\r
+ set PYTHON_COMMAND=py -3\r
+ goto check_python_available\r
+ ) else (\r
+ goto check_python2\r
+ )\r
+)\r
+if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
+ set PYTHON_COMMAND=py -3\r
+ py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
+ setlocal enabledelayedexpansion\r
+ set /p PythonCheck=<"PythonCheck.txt"\r
+ del PythonCheck.txt\r
+ if "!PythonCheck!" NEQ "TRUE" (\r
+ if not defined PYTHON_HOME if not defined PYTHONHOME (\r
+ endlocal\r
+ set PYTHON_COMMAND=\r
echo.\r
- echo !!! ERROR !!! PYTHON3 is not installed or added to environment variables\r
+ echo !!! ERROR !!! Binary python tools are missing.\r
+ echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME\r
+ echo Environment variable is not set successfully.\r
+ echo They is required to build or execute the python tools.\r
echo.\r
goto end\r
) else (\r
- goto check_freezer_path\r
+ goto check_python2\r
)\r
- ) \r
+ ) else (\r
+ goto check_freezer_path\r
+ )\r
)\r
\r
+:check_python2\r
+endlocal\r
if defined PYTHON_HOME (\r
if EXIST "%PYTHON_HOME%" (\r
- set PYTHON=%PYTHON_HOME%\python.exe\r
- goto check_freezer_path\r
- )\r
+ set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
+ goto check_python_available\r
)\r
+)\r
if defined PYTHONHOME (\r
if EXIST "%PYTHONHOME%" (\r
set PYTHON_HOME=%PYTHONHOME%\r
- set PYTHON=%PYTHON_HOME%\python.exe\r
+ set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
+ goto check_python_available\r
+ )\r
+)\r
+echo.\r
+echo !!! ERROR !!! PYTHON_HOME is not defined or The value of this variable does not exist\r
+echo.\r
+goto end\r
+:check_python_available\r
+%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
+ setlocal enabledelayedexpansion\r
+ set /p PythonCheck=<"PythonCheck.txt"\r
+ del PythonCheck.txt\r
+ if "!PythonCheck!" NEQ "TRUE" (\r
+ echo.\r
+ echo ! ERROR ! "%PYTHON_COMMAND%" is not installed or added to environment variables\r
+ echo.\r
+ goto end\r
+ ) else (\r
goto check_freezer_path\r
- )\r
)\r
- \r
- echo.\r
- echo !!! ERROR !!! Binary python tools are missing.\r
- echo PYTHON_HOME or PYTHON3_ENABLE environment variable is not set successfully.\r
- echo PYTHON_HOME or PYTHON3_ENABLE is required to build or execute the python tools.\r
- echo.\r
- goto end\r
\r
:check_freezer_path\r
+ endlocal\r
if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
\r
:print_python_info\r
echo PATH = %PATH%\r
- if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
+ if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
- echo PYTHON3 = %PYTHON%\r
+ echo PYTHON3 = %PYTHON_COMMAND%\r
) else (\r
- echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
- if defined PYTHON_HOME (\r
- echo PYTHON_HOME = %PYTHON_HOME%\r
- )\r
+ echo PYTHON3_ENABLE = FALSE\r
+ echo PYTHON_COMMAND = %PYTHON_COMMAND%\r
)\r
echo PYTHONPATH = %PYTHONPATH%\r
echo.\r
then
. $WORKSPACE/BaseTools/BuildEnv
elif [ -n "$PACKAGES_PATH" ]
- then
+ then
PATH_LIST=$PACKAGES_PATH
PATH_LIST=${PATH_LIST//:/ }
for DIR in $PATH_LIST
fi
}
-function SetupPython()
-{
- if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
- then
- if [ $origin_version ];then
+function SetupPython3()
+{
+ if [ $origin_version ];then
origin_version=
fi
for python in $(whereis python3)
fi
if [ -z $origin_version ];then
origin_version=$python_version
- export PYTHON=$python
+ export PYTHON_COMMAND=$python
continue
fi
ret=`echo "$origin_version < $python_version" |bc`
if [ "$ret" -eq 1 ]; then
origin_version=$python_version
- export PYTHON=$python
+ export PYTHON_COMMAND=$python
fi
done
+ return 0
+}
+
+function SetupPython()
+{
+ if [ $PYTHON_COMMAND ] && [ -z $PYTHON3_ENABLE ];then
+ if ( command -v $PYTHON_COMMAND >/dev/null 2>&1 );then
+ return 0
+ else
+ echo $PYTHON_COMMAND Cannot be used to build or execute the python tools.
+ return 1
+ fi
fi
-
- if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ]
+
+ if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
+ then
+ SetupPython3
+ fi
+
+ if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE != TRUE ]
then
if [ $origin_version ];then
origin_version=
if [ -z $origin_version ]
then
origin_version=$python_version
- export PYTHON=$python
+ export PYTHON_COMMAND=$python
continue
fi
ret=`echo "$origin_version < $python_version" |bc`
if [ "$ret" -eq 1 ]; then
origin_version=$python_version
- export PYTHON=$python
+ export PYTHON_COMMAND=$python
fi
done
+ return 0
fi
+
+ SetupPython3
}
function SourceEnv()