Formatted setup.ps1

This commit is contained in:
simwai
2024-05-23 12:08:10 +02:00
parent 6d261b828e
commit 1352240ec7
+23 -23
View File
@@ -148,26 +148,26 @@ function Install-Requirements {
function Test-PythonExecutable { function Test-PythonExecutable {
param( param(
[string]$PythonExecutable [string]$PythonExecutable
) )
$pythonCmd = Get-Command $PythonExecutable -ErrorAction SilentlyContinue $pythonCmd = Get-Command $PythonExecutable -ErrorAction SilentlyContinue
if ($pythonCmd) { if ($pythonCmd) {
$command = "$($pythonCmd.Source) --version 2>&1" $command = "$($pythonCmd.Source) --version 2>&1"
$versionOutput = Invoke-Expression $command $versionOutput = Invoke-Expression $command
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
$version = $versionOutput | Select-String -Pattern "Python (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value } $version = $versionOutput | Select-String -Pattern "Python (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }
Write-Log "Python version $version found using executable '$PythonExecutable'." Write-Log "Python version $version found using executable '$PythonExecutable'."
return $true return $true
} }
else { else {
Write-Log "Python executable '$PythonExecutable' not working correctly." -Level 'ERROR' Write-Log "Python executable '$PythonExecutable' not working correctly." -Level 'ERROR'
return $false return $false
} }
} }
else { else {
Write-Log "Python executable '$PythonExecutable' not found." -Level 'ERROR' Write-Log "Python executable '$PythonExecutable' not found." -Level 'ERROR'
return $false return $false
} }
} }
@@ -176,9 +176,9 @@ function Find-PythonExecutable {
$pythonExecutables = @("python", "python3", "python3.9", "python3.10", "python3.11", "C:\Python39\python.exe", "C:\Python310\python.exe", "C:\Python311\python.exe") $pythonExecutables = @("python", "python3", "python3.9", "python3.10", "python3.11", "C:\Python39\python.exe", "C:\Python310\python.exe", "C:\Python311\python.exe")
foreach ($executable in $pythonExecutables) { foreach ($executable in $pythonExecutables) {
if (Test-PythonExecutable -PythonExecutable $executable) { if (Test-PythonExecutable -PythonExecutable $executable) {
return $executable return $executable
} }
} }
return $null return $null
@@ -260,12 +260,12 @@ function Main {
# Install the selected requirement files together # Install the selected requirement files together
if ($selectedRequirementFiles.Count -gt 0) { if ($selectedRequirementFiles.Count -gt 0) {
Write-Log "Installing selected requirement files..." Write-Log "Installing selected requirement files..."
$selectedRequirementFiles | ForEach-Object { & $VenvPython -m pip install -r $_ --quiet} $selectedRequirementFiles | ForEach-Object { & $VenvPython -m pip install -r $_ --quiet }
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
Write-Log "Failed to install selected requirement files. Exiting now..." -Level 'ERROR' Write-Log "Failed to install selected requirement files. Exiting now..." -Level 'ERROR'
Exit-Script -exitCode 1 Exit-Script -exitCode 1
} }
} }
# Install freqtrade from setup using the virtual environment's Python # Install freqtrade from setup using the virtual environment's Python