$ErrorActionPreference = "Stop" $projectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path Set-Location -LiteralPath $projectRoot & (Join-Path $projectRoot 'create_shortcut.ps1') if (-not (Test-Path -LiteralPath ".venv\Scripts\python.exe")) { if (-not (Get-Command py -ErrorAction SilentlyContinue)) { throw "Python 3.11 or newer is required. Install Python from python.org, then run this script again." } & py -3 -m venv .venv if ($LASTEXITCODE -ne 0) { throw 'Virtual environment setup failed.' } } $dependencyHash = (Get-FileHash -LiteralPath 'requirements.txt' -Algorithm SHA256).Hash $dependencyMarker = Join-Path $projectRoot '.venv\requirements.sha256' $installedHash = if (Test-Path -LiteralPath $dependencyMarker) { (Get-Content -LiteralPath $dependencyMarker -Raw).Trim() } else { '' } if ($installedHash -ne $dependencyHash) { & .venv\Scripts\python.exe -m pip install --disable-pip-version-check -r requirements.txt if ($LASTEXITCODE -ne 0) { throw 'Dependency installation failed.' } Set-Content -LiteralPath $dependencyMarker -Value $dependencyHash } & .venv\Scripts\python.exe web_ui.py