demo-python/code/custom-vectorizer/scripts/init_python_env.ps1 (16 lines of code) (raw):

$pythonCmd = Get-Command python -ErrorAction SilentlyContinue if (-not $pythonCmd) { # fallback to python3 if python not found $pythonCmd = Get-Command python3 -ErrorAction SilentlyContinue } $venvPythonPath = "./scripts/.venv/scripts/python.exe" if (Test-Path -Path "/usr") { # fallback to Linux venv path $venvPythonPath = "./scripts/.venv/bin/python" } if (-not (Test-Path -Path $venvPythonPath)) { Write-Host 'Creating python virtual environment "scripts/.venv"' Start-Process -FilePath ($pythonCmd).Source -ArgumentList "-m venv ./scripts/.venv" -Wait -NoNewWindow } Write-Host 'Installing dependencies from "requirements.txt" into virtual environment' Start-Process -FilePath $venvPythonPath -ArgumentList "-m pip install -r ./scripts/requirements.txt" -Wait -NoNewWindow