Conversation
|
All changes look good. Wait for review from human collaborators. uv
|
|
Should we also migrate the artifacts originally located in |
|
According to https://docs.astral.sh/uv/reference/storage/#tool-executables I think this manifests already does that by setting all relevant env variables and then save those same folders under or maybe I am missing something? |
|
I'm referring to users who have previously installed UV via scoop. Their data resides in Lines 26 to 33 in 82c1841 |
|
Ah that is a very good point. |
|
I did some quick tests and uv seems to just pick up whatever is in the target folder. Copying over the legacy location should be a pretty transparent operation for the user. |
|
ok, first attempt. here's the overview:
this should only move previously handled by uv. here's the code in plain: # Migrate legacy UV data if it exists and the new persist directory doesn't exist
$legacy_uv = Join-Path -Path $env:APPDATA -ChildPath 'uv'
if ((Test-Path $legacy_uv) -and -not (Test-Path $persist_dir)) {
Write-Host "Migrating legacy uv data from '$legacy_uv' to '$persist_dir'." -ForegroundColor Yellow
# --- Legacy locations ---
$legacy_uv_python_data = Join-Path -Path $legacy_uv -ChildPath 'python'
$legacy_uv_python_shims = Join-Path (Join-Path $env:USERPROFILE '.local') 'bin'
$legacy_uv_tools = Join-Path -Path $legacy_uv -ChildPath 'tools'
$legacy_uv_tools_shims = Join-Path (Join-Path $env:USERPROFILE '.local') 'bin'
# --- Persist target layout ---
$persist_python_root = Join-Path $persist_dir 'python'
$persist_python_versions = Join-Path $persist_python_root 'versions'
$persist_python_shims = Join-Path $persist_python_root 'shims'
$persist_tools_root = Join-Path $persist_dir 'tools'
$persist_tools_versions = Join-Path $persist_tools_root 'versions'
$persist_tools_shims = Join-Path $persist_tools_root 'shims'
# Create target directories
$null = New-Item -ItemType Directory -Force -Path @(
$persist_dir,
$persist_python_root, $persist_python_versions, $persist_python_shims,
$persist_tools_root, $persist_tools_versions, $persist_tools_shims
)
# ---- Move Python "versions" content ----
if (Test-Path $legacy_uv_python_data) {
Write-Host "-> Moving Python versions from '$legacy_uv_python_data' to '$persist_python_versions'..." -ForegroundColor Cyan
Get-ChildItem -Path $legacy_uv_python_data -Force |
ForEach-Object {
Move-Item -LiteralPath $_.FullName -Destination $persist_python_versions -Force -ErrorAction Stop
}
} else {
Write-Host "-> No legacy Python versions found at '$legacy_uv_python_data'." -ForegroundColor DarkGray
}
# ---- Move Python shims: only python.exe or python<major>.<minor>.exe ----
if (Test-Path $legacy_uv_python_shims) {
$pythonShimRegex = '^(python(\d+\.\d+)?)\.exe$' # matches python.exe and pythonX.Y.exe
$pythonShims = Get-ChildItem -Path $legacy_uv_python_shims -File -Force |
Where-Object { $_.Name -match $pythonShimRegex }
if ($pythonShims) {
Write-Host "-> Moving Python shims to '$persist_python_shims': $($pythonShims.Name -join ', ')" -ForegroundColor Cyan
foreach ($shim in $pythonShims) {
Move-Item -LiteralPath $shim.FullName -Destination (Join-Path $persist_python_shims $shim.Name) -Force -ErrorAction Stop
}
} else {
Write-Host "-> No valid Python shims found in '$legacy_uv_python_shims'." -ForegroundColor DarkGray
}
} else {
Write-Host "-> Legacy Python shim directory not found at '$legacy_uv_python_shims'." -ForegroundColor DarkGray
}
# ---- Move Tools "versions" content ----
if (Test-Path $legacy_uv_tools) {
Write-Host "-> Moving Tools versions from '$legacy_uv_tools' to '$persist_tools_versions'..." -ForegroundColor Cyan
Get-ChildItem -Path $legacy_uv_tools -Force |
ForEach-Object {
Move-Item -LiteralPath $_.FullName -Destination $persist_tools_versions -Force -ErrorAction Stop
}
} else {
Write-Host "-> No legacy Tools found at '$legacy_uv_tools'." -ForegroundColor DarkGray
}
# ---- Move Tools shims: only those matching folder names under /tools/versions ----
# Build allowlist from folder names directly under $persist_tools_versions
$toolNames = @()
if (Test-Path $persist_tools_versions) {
$toolNames = Get-ChildItem -Path $persist_tools_versions -Directory -Force |
Select-Object -ExpandProperty Name
}
if ($toolNames.Count -gt 0 -and (Test-Path $legacy_uv_tools_shims)) {
# For each tool name, move "<tool>.exe" if present
$moved = @()
foreach ($tool in $toolNames) {
$candidate = Join-Path $legacy_uv_tools_shims ($tool + '.exe')
if (Test-Path $candidate) {
Move-Item -LiteralPath $candidate -Destination (Join-Path $persist_tools_shims ($tool + '.exe')) -Force -ErrorAction Stop
$moved += ($tool + '.exe')
}
}
if ($moved.Count -gt 0) {
Write-Host "-> Moved tool shims to '$persist_tools_shims': $($moved -join ', ')" -ForegroundColor Cyan
} else {
Write-Host "-> No matching tool shims found in '$legacy_uv_tools_shims' for tools: $($toolNames -join ', ')." -ForegroundColor DarkGray
}
} else {
if (-not (Test-Path $legacy_uv_tools_shims)) {
Write-Host "-> Legacy tools shim directory not found at '$legacy_uv_tools_shims'." -ForegroundColor DarkGray
} else {
Write-Host "-> No tool folders found under '$persist_tools_versions'; skipping shim migration." -ForegroundColor DarkGray
}
}
} elseif ((Test-Path $legacy_uv) -and (Test-Path $persist_dir)) {
Write-Host "Found both '$legacy_uv' and '$persist_dir'. Skipping auto-migration; please migrate manually if needed." -ForegroundColor Yellow
} |
<manifest-name[@version]|chore>: <general summary of the pull request>Hey,
This might be a bit opinionated, but I wanted uv to behave like pyenv (when installed through scoop) behaved.
With this change scoops makes uv store its python and tool installation paths within the scoop uv folder.
I currently have been using this manifest for the past year or so without issues regarding uv.
It also automatically sets the python and tool shims folders in the path so that it's automatically available.
If too breaking/opinionated feel free to close, but wanted to give the option if it was ever considered.
Cheers.
Related #6955