Small utility to activate python venvs without hassle
0

Configure Feed

Select the types of activity you want to include in your feed.

Add powershell script

Humberto Rocha (Nov 16, 2023, 2:58 PM EST) d3cd4320 d9a0e49f

+27
+27
activate.ps1
··· 1 + # Utility command to activate local Python venv 2 + # located at the same folder of the code project 3 + 4 + function activate 5 + { 6 + $current_folder = Split-Path -Path (Get-Location ).Path -Leaf 7 + $venv_candidates = @('.venv', 'venv', '.env', ".hatch/${current_folder}") 8 + 9 + foreach ($candidate in $venv_candidates) 10 + { 11 + if (Test-Path -Path $candidate -PathType Container) 12 + { 13 + $venv = $candidate 14 + } 15 + } 16 + 17 + $venv = "${venv}/Scripts/Activate.ps1" 18 + 19 + if (Test-Path -Path $venv -PathType Leaf) 20 + { 21 + . $venv 22 + } 23 + else 24 + { 25 + Write-Output 'venv not found' 26 + } 27 + }