#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
-# If a python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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 python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
- python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+ python_exe=${PYTHON}
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_HOME%\python.exe -m %ToolName%.%ToolName% %*\r
+@%PYTHON% -m %ToolName%.%ToolName% %*\r
@setlocal\r
@set ToolName=%~n0%\r
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python\r
-@%PYTHON_HOME%\python.exe -m %ToolName%.EccMain %*\r
+@%PYTHON% -m %ToolName%.EccMain %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*\r
+@%PYTHON% %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_HOME%\python.exe -m %ToolName%.%ToolName% %*\r
+@%PYTHON% -m %ToolName%.%ToolName% %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
@setlocal\r
@set ToolName=%~n0%\r
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
all: c\r
\r
c :\r
- @$(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C\r
+ @$(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C\r
\r
\r
subdirs: $(SUBDIRS)\r
- @$(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $**\r
+ @$(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $**\r
\r
.PHONY: clean\r
clean:\r
- $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)\r
+ $(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)\r
\r
.PHONY: cleanall\r
cleanall:\r
- $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)\r
+ $(PYTHON) $(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_HOME)\python.exe Makefiles\NmakeSubdirs.py all $**\r
+ @$(PYTHON) 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_HOME)\python.exe Makefiles\NmakeSubdirs.py all $**\r
+ @$(PYTHON) Makefiles\NmakeSubdirs.py all $**\r
\r
install: $(LIB_PATH) $(BIN_PATH)\r
@echo.\r
\r
.PHONY: clean\r
clean:\r
- @$(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)\r
+ @$(PYTHON) Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)\r
\r
.PHONY: cleanall\r
cleanall:\r
- @$(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)\r
+ @$(PYTHON) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)\r
\r
!INCLUDE Makefiles\ms.rule\r
\r
all: test\r
\r
test:\r
- @if command -v python2 >/dev/null 2>&1; then python2 RunTests.py; else python RunTests.py; fi\r
+ @if command -v $(PYTHON) >/dev/null 1; then $(PYTHON) RunTests.py; else python RunTests.py; fi\r
\r
clean:\r
find . -name '*.pyc' -exec rm '{}' ';'\r
echo.\r
\r
:check_build_environment\r
- set PYTHONHASHSEED=0\r
- if defined BASETOOLS_PYTHON_SOURCE goto VisualStudioAvailable\r
+ set PYTHONHASHSEED=1\r
\r
if not defined BASE_TOOLS_PATH (\r
if not exist "Source\C\Makefile" (\r
)\r
)\r
\r
- if not defined PYTHON_HOME (\r
- if defined PYTHONHOME (\r
- set PYTHON_HOME=%PYTHONHOME%\r
- ) else (\r
+:defined_python\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
echo.\r
- echo !!! ERROR !!! Binary python tools are missing. PYTHON_HOME environment variable is not set.\r
- echo PYTHON_HOME is required to build or execute the python tools.\r
+ echo !!! ERROR !!! PYTHON3 is not installed or added to environment variables\r
echo.\r
goto end\r
+ ) else (\r
+ goto check_freezer_path\r
+ )\r
+ ) \r
+)\r
+\r
+if defined PYTHON_HOME (\r
+ if EXIST "%PYTHON_HOME%" (\r
+ set PYTHON=%PYTHON_HOME%\python.exe\r
+ goto check_freezer_path\r
+ )\r
+ )\r
+if defined PYTHONHOME (\r
+ if EXIST "%PYTHONHOME%" (\r
+ set PYTHON_HOME=%PYTHONHOME%\r
+ set PYTHON=%PYTHON_HOME%\python.exe\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
+ 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
set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
\r
+:print_python_info\r
echo PATH = %PATH%\r
- echo PYTHON_HOME = %PYTHON_HOME%\r
+ if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
+ echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
+ echo PYTHON3 = %PYTHON%\r
+ ) else (\r
+ echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
+ if defined PYTHON_HOME (\r
+ echo PYTHON_HOME = %PYTHON_HOME%\r
+ )\r
+ )\r
echo PYTHONPATH = %PYTHONPATH%\r
echo.\r
\r
# Set $WORKSPACE
#
export WORKSPACE=`pwd`
- export PYTHONHASHSEED=0\r
+ export PYTHONHASHSEED=1
return 0
}
fi
}
+function SetupPython()
+{
+ if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
+ then
+ for python in $(which python3)
+ do
+ python=$(echo $python | grep "[[:digit:]]$" || true)
+ python_version=${python##*python}
+ if [ -z "${python_version}" ];then
+ continue
+ fi
+ if [ -z $origin_version ];then
+ origin_version=$python_version
+ export PYTHON=$python
+ continue
+ fi
+ ret=`echo "$origin_version < $python_version" |bc`
+ if [ "$ret" -eq 1 ]; then
+ origin_version=$python_version
+ export PYTHON=$python
+ fi
+ done
+ fi
+
+ if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ]
+ then
+ for python in $(which python2)
+ do
+ python=$(echo $python | grep "[[:digit:]]$" || true)
+ python_version=${python##*python}
+ if [ -z "${python_version}" ];then
+ continue
+ fi
+ if [ -z $origin_version ] || [ $origin_version -ge 3 ]
+ then
+ origin_version=$python_version
+ export PYTHON=$python
+ continue
+ fi
+ ret=`echo "$origin_version < $python_version" |bc`
+ if [ "$ret" -eq 1 ]; then
+ origin_version=$python_version
+ export PYTHON=$python
+ fi
+ done
+ fi
+}
+
function SourceEnv()
{
SetWorkspace &&
SetupEnv
+ SetupPython
}
I=$#