Try python2 before python.

This commit is contained in:
Ben Vanik 2015-11-25 15:22:53 -08:00
parent dfd92757a9
commit 57f2504e1f
1 changed files with 23 additions and 6 deletions

29
xb.bat
View File

@ -9,7 +9,7 @@ REM ============================================================================
CALL :check_python CALL :check_python
IF %_RESULT% NEQ 0 ( IF %_RESULT% NEQ 0 (
ECHO ERROR: ECHO.
ECHO Python 2.7 must be installed and on PATH: ECHO Python 2.7 must be installed and on PATH:
ECHO https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi ECHO https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi
GOTO :exit_error GOTO :exit_error
@ -20,7 +20,7 @@ REM ============================================================================
REM Trampoline into xenia-build REM Trampoline into xenia-build
REM ============================================================================ REM ============================================================================
python xenia-build %* %PYTHON_EXE% xenia-build %*
EXIT /b %ERRORLEVEL% EXIT /b %ERRORLEVEL%
@ -30,15 +30,32 @@ REM ============================================================================
:check_python :check_python
SETLOCAL SETLOCAL
1>NUL 2>NUL CMD /c where python SET FOUND_PYTHON_EXE=""
IF %ERRORLEVEL% NEQ 0 ( 1>NUL 2>NUL CMD /c where python2
IF NOT ERRORLEVEL 1 (
ECHO FOUND PYTHON 2
SET FOUND_PYTHON_EXE=python2
)
IF %FOUND_PYTHON_EXE% EQU "" (
1>NUL 2>NUL CMD /c where python
IF NOT ERRORLEVEL 1 (
SET FOUND_PYTHON_EXE=python
)
)
IF %FOUND_PYTHON_EXE% EQU "" (
ECHO ERROR: no Python executable found on PATH.
ECHO Make sure you can run 'python' or 'python2' in a Command Prompt.
ENDLOCAL & SET _RESULT=1 ENDLOCAL & SET _RESULT=1
GOTO :eof GOTO :eof
) )
CMD /c python -c "import sys; sys.exit(1 if not sys.version_info[:2] == (2, 7) else 0)" CMD /C %FOUND_PYTHON_EXE% -c "import sys; sys.exit(1 if not sys.version_info[:2] == (2, 7) else 0)"
IF %ERRORLEVEL% NEQ 0 ( IF %ERRORLEVEL% NEQ 0 (
ECHO ERROR: Python version mismatch - not 2.7
ENDLOCAL & SET _RESULT=1 ENDLOCAL & SET _RESULT=1
GOTO :eof GOTO :eof
) )
ENDLOCAL & SET _RESULT=0 ENDLOCAL & (
SET _RESULT=0
SET PYTHON_EXE=%FOUND_PYTHON_EXE%
)
GOTO :eof GOTO :eof