diff --git a/scripts/Common.ps1 b/scripts/Common.ps1 index 4ae23a5..f4eff55 100644 --- a/scripts/Common.ps1 +++ b/scripts/Common.ps1 @@ -43,7 +43,7 @@ function Sync-Uv { ) if (Get-Command 'uv' -ErrorAction 'Ignore') { $Uv = 'uv' } else { - $Uv = Get-Item 'bin/uv.???' -ErrorAction 'Ignore' + $Uv = Get-Item 'bin/uv.*' -ErrorAction 'Ignore' } # ? Prepend local `bin` to PATH if (!($Bin = Get-Item 'bin' -ErrorAction 'Ignore')) { @@ -56,7 +56,7 @@ function Sync-Uv { if ($CI) { ("PATH=$Env:PATH", "UV_TOOL_BIN_DIR=$Bin") | Add-Content $EnvFile } - # ? + # ? Install `uv` if ((!$Uv -or !(& $Uv --version | Select-String $Version))) { 'Installing uv' | Write-Progress $OrigCargoHome = $Env:CARGO_HOME @@ -66,6 +66,6 @@ function Sync-Uv { else { curl --proto '=https' --tlsv1.2 -LsSf "https://github.com/astral-sh/uv/releases/download/$Version/uv-installer.sh" | sh } if ($OrigCargoHome) { $Env:CARGO_HOME = $OrigCargoHome } 'uv installed' | Write-Progress -Done - return Get-Item 'bin/uv.???' + return Get-Item 'bin/uv.*' } } diff --git a/scripts/Initialize-Shell.ps1 b/scripts/Initialize-Shell.ps1 index ce430fd..070667e 100644 --- a/scripts/Initialize-Shell.ps1 +++ b/scripts/Initialize-Shell.ps1 @@ -29,14 +29,16 @@ function Set-Env { # ? Sync the virtual environment Sync-Uv - if (!(Test-Path '.venv')) { uv venv --python $Version } - if ($IsWindows) { .venv/scripts/activate.ps1 } else { .venv/bin/activate.ps1 } - if (!(python --version | Select-String -Pattern $([Regex]::Escape($Version)))) { - 'Virtual environment is the wrong Python version.' | Write-Progress -Info - 'Creating virtual environment with correct Python version' | Write-Progress - Remove-Item -Recurse -Force $Env:VIRTUAL_ENV - uv venv --python $Version + if (!$CI) { + if (!(Test-Path '.venv')) { uv venv --python $Version } if ($IsWindows) { .venv/scripts/activate.ps1 } else { .venv/bin/activate.ps1 } + if (!(python --version | Select-String -Pattern $([Regex]::Escape($Version)))) { + 'Virtual environment is the wrong Python version.' | Write-Progress -Info + 'Creating virtual environment with correct Python version' | Write-Progress + Remove-Item -Recurse -Force $Env:VIRTUAL_ENV + uv venv --python $Version + if ($IsWindows) { .venv/scripts/activate.ps1 } else { .venv/bin/activate.ps1 } + } } if (!(Get-Command 'context_models_tools' -ErrorAction 'Ignore')) { 'Installing tools' | Write-Progress