Skip to content

Commit

Permalink
Try not doing venv in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Sep 16, 2024
1 parent 33827ab commit 9b3c703
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions scripts/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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
Expand All @@ -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.*'
}
}
16 changes: 9 additions & 7 deletions scripts/Initialize-Shell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b3c703

Please sign in to comment.