Something went wrong. Try again.
Small utility to activate python venvs without hassle
Something went wrong. Try again.
12345678910111213141516171819202122232425262728# Utility command to activate local Python venv# located at the same folder of the code project
function activate{ $current_folder = Split-Path -Path (Get-Location ).Path -Leaf $venv_candidates = @('.venv', 'venv', '.env', ".hatch/${current_folder}")
foreach ($candidate in $venv_candidates) { if (Test-Path -Path $candidate -PathType Container) { $venv = $candidate } }
$venv = "${venv}/Scripts/Activate.ps1"
if (Test-Path -Path $venv -PathType Leaf) { . $venv } else { Write-Output 'venv not found' }}