Fix Python runtime cleanup on upgrade

This commit is contained in:
oliver 2026-10-12 17:11:48 +08:00
parent 5e80932c4a
commit 19d4597b94
5 changed files with 16 additions and 7 deletions

View file

@ -20,7 +20,7 @@ Zip packages are **not** published. Releases ship **Setup.exe only**.
**Installer:** English + 简体中文 (language dialog). Icons use `packaging/assets/netx.ico`.
**Offline:** Setup ships portable PostgreSQL, **`python/runtime` + `.venv`** (portable; not tied to the build PC’s user profile), and WinSW. **First install** shows the Database page (built-in or external PostgreSQL; external credentials validated with `psql SELECT 1`). **Re-running Setup when `%ProgramData%\NetX\.env` has `NETX_DB_MODE` or a non-empty legacy `NETX_DATABASE_URL`** skips the DB wizard by default. Update stops and resumes an installed Windows service or startup task while replacing files. Service install uses bundled WinSW. Auto-update still needs network later, and is unchecked by default.
**Offline:** Setup ships portable PostgreSQL, **`python/runtime` + `.venv`** (portable; not tied to the build PC’s user profile), and WinSW. On upgrade, Setup removes the old runtime and virtual environment before copying the bundled pair, preventing stale standard-library files when Python versions have different layouts. **First install** shows the Database page (built-in or external PostgreSQL; external credentials validated with `psql SELECT 1`). **Re-running Setup when `%ProgramData%\NetX\.env` has `NETX_DB_MODE` or a non-empty legacy `NETX_DATABASE_URL`** skips the DB wizard by default. Update stops and resumes an installed Windows service or startup task while replacing files. Service install uses bundled WinSW. Auto-update still needs network later, and is unchecked by default.
**OS:** Windows 10/11 or Windows Server **2016+** recommended. Packaging scripts are UTF-8 **with BOM** so Chinese UI works on Windows PowerShell 5.x. The Windows release workflow pins bundled Python to **3.12**, so local release builds should use the same version for consistent artifacts.

View file

@ -210,6 +210,8 @@ if ($CreateVenv) {
if (-not (Test-NetxVenvRunnable -VenvPython $venvPy)) {
throw "venv_not_runnable_after_build: check python/runtime copy"
}
& $venvPy -c "from pathlib import Path; import glob; print(Path.cwd()); print(glob.__file__)"
if ($LASTEXITCODE -ne 0) { throw "python_stdlib_smoke_failed: pathlib/glob import mismatch" }
& $venvPy -m pip install --upgrade pip
& $venvPy -m pip install -r (Join-Path $stage "requirements.txt")
@ -219,6 +221,8 @@ if ($CreateVenv) {
if (-not (Test-NetxVenvRunnable -VenvPython $venvPy)) {
throw "venv_not_runnable_after_pip"
}
& $venvPy -c "from pathlib import Path; import glob; print(Path.cwd()); print(glob.__file__)"
if ($LASTEXITCODE -ne 0) { throw "python_stdlib_smoke_failed_after_pip: pathlib/glob import mismatch" }
Write-Host "==> Slimming .venv (drop tests / __pycache__ / *.pyc)"
$site = Join-Path $stage ".venv\Lib\site-packages"

View file

@ -5,7 +5,7 @@
#define MyAppName "NetX"
#ifndef MyAppVersion
#define MyAppVersion "0.4.14"
#define MyAppVersion "0.4.15"
#endif
#define MyAppPublisher "NetX"
#define MyAppURL "https://github.com/hansjone/netx"
@ -154,6 +154,11 @@ Name: "{commonappdata}\NetX\pgdata"; Permissions: users-modify
Name: "{commonappdata}\NetX\backups"; Permissions: users-modify
[InstallDelete]
; Python minor releases can change stdlib layout (for example pathlib.py -> pathlib\\).
; Remove the previous runtime and venv before copying the new ones so an upgrade
; cannot leave orphaned modules that shadow files from the shipped Python version.
Type: filesandordirs; Name: "{app}\python\runtime"
Type: filesandordirs; Name: "{app}\.venv"
; Remove legacy desktop shortcuts from older Setup builds (keep a single NetX icon).
Type: files; Name: "{commondesktop}\NetX Start.lnk"
Type: files; Name: "{commondesktop}\NetX First-time setup.lnk"

View file

@ -1,11 +1,11 @@
{
"channel": "stable",
"latest": "0.4.14",
"latest": "0.4.15",
"min_compatible": "0.3.0",
"notes_url": "https://github.com/hansjone/netx/releases/tag/v0.4.14",
"notes_url": "https://github.com/hansjone/netx/releases/tag/v0.4.15",
"windows": {
"url": "https://github.com/hansjone/netx/releases/download/v0.4.14/NetX-Setup-0.4.14.exe",
"setup_url": "https://github.com/hansjone/netx/releases/download/v0.4.14/NetX-Setup-0.4.14.exe",
"url": "https://github.com/hansjone/netx/releases/download/v0.4.15/NetX-Setup-0.4.15.exe",
"setup_url": "https://github.com/hansjone/netx/releases/download/v0.4.15/NetX-Setup-0.4.15.exe",
"package": "setup",
"sha256": "",
"size": 0