diff --git a/docs/building.md b/docs/building.md index 061bb9f32..05eaff6f1 100644 --- a/docs/building.md +++ b/docs/building.md @@ -12,7 +12,7 @@ drivers. * [Visual Studio 2022](https://www.visualstudio.com/downloads/) * CMake 3.10+ (or C++ CMake tools for Windows) * Windows 11 SDK version 10.0.22000.0 (for Visual Studio 2022, this or any newer version) -* [Python 3.9+](https://www.python.org/downloads/) +* [Python 3.9+ 64-bit](https://www.python.org/downloads/) * Ensure Python is in PATH. ``` diff --git a/xb.bat b/xb.bat index 4c59eb65c..8fc7b4107 100644 --- a/xb.bat +++ b/xb.bat @@ -7,12 +7,10 @@ REM ============================================================================ REM Environment Validation REM ============================================================================ -SET "PYTHON_MINIMUM_VERSION[0]=3" -SET "PYTHON_MINIMUM_VERSION[1]=9" CALL :check_python IF %_RESULT% NEQ 0 ( ECHO. - ECHO Python %PYTHON_MINIMUM_VERSION[0]%.%PYTHON_MINIMUM_VERSION[1]%+ must be installed and on PATH: + ECHO Python 3.9+ must be installed and on PATH: ECHO https://www.python.org/ GOTO :eof ) @@ -35,22 +33,16 @@ SETLOCAL ENABLEDELAYEDEXPANSION SET FOUND_PATH="" -SET "CANDIDATE_PATHS[0]=C:\python314\python.exe" -SET "CANDIDATE_PATHS[1]=C:\python313\python.exe" -SET "CANDIDATE_PATHS[2]=C:\python312\python.exe" -SET "CANDIDATE_PATHS[3]=C:\python311\python.exe" -SET "CANDIDATE_PATHS[4]=C:\python310\python.exe" -SET "CANDIDATE_PATHS[5]=C:\python%PYTHON_MINIMUM_VERSION[0]%%PYTHON_MINIMUM_VERSION[1]%\python.exe" SET "CANDIDATE_PATHS[6]=%WINDIR%\py.exe" -SET OUTPUT_INDEX=7 +SET OUTPUT_INDEX=1 -FOR /F "usebackq delims=" %%L IN (`2^>NUL where python3`) DO ( +FOR /F "usebackq delims=" %%L IN (`2^>NUL where python`) DO ( IF %%~zL NEQ 0 ( SET "CANDIDATE_PATHS[!OUTPUT_INDEX!]=%%L" SET /A OUTPUT_INDEX+=1 ) ) -FOR /F "usebackq delims=" %%L IN (`2^>NUL where python`) DO ( +FOR /F "usebackq delims=" %%L IN (`2^>NUL where python3`) DO ( IF %%~zL NEQ 0 ( SET "CANDIDATE_PATHS[!OUTPUT_INDEX!]=%%L" SET /A OUTPUT_INDEX+=1 @@ -77,14 +69,6 @@ IF "%FOUND_PATH%"=="" ( GOTO :eof ) -CMD /C ""%FOUND_PATH%" -c "import sys; sys.exit(1 if not sys.version_info[:2] ^>= (%PYTHON_MINIMUM_VERSION[0]%, %PYTHON_MINIMUM_VERSION[1]%) else 0)" -IF %ERRORLEVEL% NEQ 0 ( - ECHO ERROR: Python version mismatch, not at least %PYTHON_MINIMUM_VERSION[0]%.%PYTHON_MINIMUM_VERSION[1]%. - ECHO Found Python executable was "%FOUND_PATH%". - ENDLOCAL & SET _RESULT=1 - GOTO :eof -) - ENDLOCAL & ( SET _RESULT=0 SET "PYTHON_EXE=%FOUND_PATH%" diff --git a/xb.ps1 b/xb.ps1 index 95979ccea..d5afc9bb5 100644 --- a/xb.ps1 +++ b/xb.ps1 @@ -1,27 +1,15 @@ -function Write-FatalError($message) { - [Console]::ForegroundColor = 'red' - [Console]::Error.WriteLine($message) - [Console]::ResetColor() - Exit 1 -} - -$pythonExecutables = 'python', 'python3' +$pythonExecutables = "python", "python3", "py" foreach ($pythonExecutable in $pythonExecutables) { if (!$pythonPath) { $pythonPath = powershell -NoLogo -NonInteractive "(Get-Command -ErrorAction SilentlyContinue $pythonexecutable).Definition" # Hack to not give command suggestion - } else { - break + if ($pythonPath) { + break + } } } # Neither found, error and exit -$pythonMinimumVer = 3,9 if (!$pythonPath) { - Write-FatalError "ERROR: Python $($pythonMinimumVer[0]).$($pythonMinimumVer[1])+ must be installed and on PATH:`nhttps://www.python.org/" -} - -& $pythonPath -c "import sys; sys.exit(1 if not sys.version_info[:2] >= ($($pythonMinimumVer[0]), $($pythonMinimumVer[1])) else 0)" -if ($LASTEXITCODE -gt 0) { - Write-FatalError "ERROR: Python version mismatch, not at least $($pythonMinimumVer[0]).$($pythonMinimumVer[1]).`nFound Python executable was `"$($pythonPath)`"." + Throw "ERROR: Python 3.9+ 64-bit must be installed and on PATH:`nhttps://www.python.org/" } & $pythonPath "$($PSScriptRoot)/xenia-build" $args diff --git a/xenia-build b/xenia-build index df80272d5..ae4e86625 100755 --- a/xenia-build +++ b/xenia-build @@ -139,8 +139,8 @@ def main(): # Check python version. python_minimum_ver = 3,9 - if not sys.version_info[:2] >= (python_minimum_ver[0], python_minimum_ver[1]): - print(f"ERROR: Python {python_minimum_ver[0]}.{python_minimum_ver[1]} must be installed and on PATH") + if not sys.version_info[:2] >= (python_minimum_ver[0], python_minimum_ver[1]) or not sys.maxsize > 2**32: + print(f"ERROR: Python {python_minimum_ver[0]}.{python_minimum_ver[1]}+ 64-bit must be installed and on PATH") sys.exit(1) # Grab Visual Studio version and execute shell to set up environment.