2020-08-26 23:25:17 +00:00
function Write-FatalError($message ) {
[ Console ] :: ForegroundColor = 'red'
[ Console ] :: Error . WriteLine ( $message )
[ Console ] :: ResetColor ( )
Exit 1
}
2022-03-09 15:07:46 +00:00
$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
}
2020-08-26 23:25:17 +00:00
}
# Neither found, error and exit
2022-03-09 15:07:46 +00:00
$pythonMinimumVer = 3 , 6
if ( ! $pythonPath ) {
Write-FatalError " ERROR: Python $( $pythonMinimumVer [ 0 ] ) . $( $pythonMinimumVer [ 1 ] ) + must be installed and on PATH: `n https://www.python.org/ "
2020-08-26 23:25:17 +00:00
}
2022-03-09 15:07:46 +00:00
& $pythonPath -c " import sys; sys.exit(1 if not sys.version_info[:2] >= ( $( $pythonMinimumVer [ 0 ] ) , $( $pythonMinimumVer [ 1 ] ) ) else 0) "
2020-08-26 23:25:17 +00:00
if ( $LASTEXITCODE -gt 0 ) {
2022-03-09 15:07:46 +00:00
Write-FatalError " ERROR: Python version mismatch, not at least $( $pythonMinimumVer [ 0 ] ) . $( $pythonMinimumVer [ 1 ] ) . `n Found Python executable was `" $( $pythonPath ) `" . "
2020-08-26 23:25:17 +00:00
}
2022-03-09 15:07:46 +00:00
& $pythonPath " $( $PSScriptRoot ) /xenia-build " $args