mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 02:00:46 +08:00
Release 0.4.12: update/reinstall mode and post-install venv repair.
Interactive Setup asks update vs reinstall; elevated install relinks .venv so tray start works under Program Files. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
372138d9a1
commit
ccd75a9c09
7 changed files with 246 additions and 28 deletions
|
|
@ -404,8 +404,23 @@ function Repair-NetxShippedVenv {
|
|||
"version = $ver",
|
||||
"executable = $rtPyAbs"
|
||||
)
|
||||
Set-Content -LiteralPath $cfgPath -Value ($lines -join "`r`n") -Encoding ascii
|
||||
return $true
|
||||
$desired = ($lines -join "`r`n")
|
||||
# Skip write when already correct — Users cannot modify Program Files after Setup.
|
||||
try {
|
||||
$cur = ([IO.File]::ReadAllText($cfgPath) -replace "`r`n", "`n" -replace "`r", "`n").Trim()
|
||||
$want = ($desired -replace "`r`n", "`n" -replace "`r", "`n").Trim()
|
||||
if ($cur -eq $want) {
|
||||
return $true
|
||||
}
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
Set-Content -LiteralPath $cfgPath -Value $desired -Encoding ascii -ErrorAction Stop
|
||||
return $true
|
||||
} catch {
|
||||
# Non-elevated tray/start: leave cfg as-is; caller may still run if paths happen to work.
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Test-NetxVenvRunnable {
|
||||
|
|
@ -446,7 +461,11 @@ function Ensure-NetxVenv {
|
|||
$rtPy = Join-Path (Get-NetxBundledPythonRoot -ProgramRoot $ProgramRoot) "python.exe"
|
||||
|
||||
if (Test-Path -LiteralPath $rtPy) {
|
||||
$null = Repair-NetxShippedVenv -ProgramRoot $ProgramRoot
|
||||
try {
|
||||
$null = Repair-NetxShippedVenv -ProgramRoot $ProgramRoot
|
||||
} catch {
|
||||
# Access denied under Program Files when not elevated — ignore if venv already runs.
|
||||
}
|
||||
}
|
||||
|
||||
if ((Test-Path -LiteralPath $venvPy) -and -not $ForcePip) {
|
||||
|
|
@ -455,11 +474,19 @@ function Ensure-NetxVenv {
|
|||
}
|
||||
Write-Host "[WARN] Shipped .venv exists but Python cannot start (broken pyvenv.cfg or missing runtime)." -ForegroundColor Yellow
|
||||
if (Test-Path -LiteralPath $rtPy) {
|
||||
$null = Repair-NetxShippedVenv -ProgramRoot $ProgramRoot
|
||||
if (Test-NetxVenvRunnable -VenvPython $venvPy) {
|
||||
$repaired = $false
|
||||
try {
|
||||
$repaired = [bool](Repair-NetxShippedVenv -ProgramRoot $ProgramRoot)
|
||||
} catch {
|
||||
$repaired = $false
|
||||
}
|
||||
if ($repaired -and (Test-NetxVenvRunnable -VenvPython $venvPy)) {
|
||||
Write-Host "==> Repaired .venv to use bundled python/runtime" -ForegroundColor Green
|
||||
return $venvPy
|
||||
}
|
||||
if (-not $repaired) {
|
||||
throw "venv_needs_admin_repair: pyvenv.cfg still points at the build PC. Re-run Setup (Update) as Administrator, or Start Menu → Reconfigure database once elevated."
|
||||
}
|
||||
}
|
||||
if (-not $ForcePip) {
|
||||
throw "venv_not_runnable: reinstall NetX Setup (ships python/runtime + .venv) or run repair as admin"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue