diff options
| author | Margen67 <Margen67@users.noreply.github.com> | 2022-03-09 07:07:46 -0800 |
|---|---|---|
| committer | Rick Gibbed <rick@gibbed.us> | 2022-07-21 08:31:35 -0500 |
| commit | 74d83e4af8208417c8af33d5fbab87ab1606f15a (patch) | |
| tree | 23b2808941045bb98bf0209b44116986135bf949 /xb.ps1 | |
| parent | 6ff312afb1aa5a5d4eebc3c9361095a702dfeb2a (diff) | |
Python/xenia-build/xb fixes
Use variable for Python version to make upgrading easier.
xb.bat:
Update copyright date.
Add candidate paths.
xb.ps1
Properly use found python executable.
More consistency with .bat.
Don't spew unnecessary errors, etc.
EOF newline.
Diffstat (limited to 'xb.ps1')
| -rw-r--r-- | xb.ps1 | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -5,20 +5,23 @@ function Write-FatalError($message) { Exit 1 } -$pythonPath = Get-Command python | Select-Object -ExpandProperty Definition - -# Check for 'python3' if 'python' isn't found -if ([string]::IsNullOrEmpty($pythonPath)) { - $pythonPath = Get-Command python3 | Select-Object -ExpandProperty Definition +$pythonExecutables = 'python', 'python3' +foreach ($pythonExecutable in $pythonExecutables) { + if (!$pythonPath) { + $pythonPath = powershell -NoLogo -NonInteractive "(Get-Command -ErrorAction SilentlyContinue $pythonexecutable).Definition" # Hack to not give command suggestion + } else { + break + } } # Neither found, error and exit -if ([string]::IsNullOrEmpty($pythonPath)) { - Write-FatalError "ERROR: no Python executable found on PATH.`nMake sure you can run 'python' or 'python3' in a Command Prompt." +$pythonMinimumVer = 3,6 +if (!$pythonPath) { + Write-FatalError "ERROR: Python $($pythonMinimumVer[0]).$($pythonMinimumVer[1])+ must be installed and on PATH:`nhttps://www.python.org/" } -python -c "import sys; sys.exit(1 if not sys.version_info[:2] >= (3, 4) else 0)" +& $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 3.4.`nFound Python executable was $($pythonPath)" + Write-FatalError "ERROR: Python version mismatch, not at least $($pythonMinimumVer[0]).$($pythonMinimumVer[1]).`nFound Python executable was `"$($pythonPath)`"." } -python "$($PSScriptRoot)/xenia-build" $args
\ No newline at end of file +& $pythonPath "$($PSScriptRoot)/xenia-build" $args |
