-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-python.ps1
More file actions
26 lines (20 loc) · 871 Bytes
/
setup-python.ps1
File metadata and controls
26 lines (20 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Write-Host "`nSetting up the Python environment ...`n"
Write-Host "1) Creating Python virtual environment ...`n"
$pythonCmd = Get-Command python -ErrorAction SilentlyContinue
if (-not $pythonCmd) {
# fallback to python3 if Python not found
$pythonCmd = Get-Command python3 -ErrorAction SilentlyContinue
}
Start-Process -FilePath ($pythonCmd).Source -ArgumentList "-m venv ./python_env" -Wait -NoNewWindow
$venvPythonPath = "./python_env/scripts/python.exe"
if (Test-Path -Path "/usr") {
# fallback to Linux venv path
$venvPythonPath = "./python_env/bin/python"
}
Write-Host "2) Restoring Python packages ...`n"
Start-Process -FilePath $venvPythonPath -ArgumentList "-m pip install -r requirements.txt" -Wait -NoNewWindow
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to restore Python packages"
exit $LASTEXITCODE
}
Write-Host "`n`nDONE!`n"