From f9b6f2192346ef100fbe51393a2e24d1f8744993 Mon Sep 17 00:00:00 2001 From: Domi31tls Date: Thu, 2 Jul 2026 11:25:47 +0200 Subject: [PATCH] =?UTF-8?q?build:=20purge=20torch=20venv=20GUI=20V6=20+=20?= =?UTF-8?q?pr=C3=A9cache=20OnnxTR=20+=20version=20release=20unifi=C3=A9e?= =?UTF-8?q?=20(P0-3/P0-4/P1-7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- scripts/build_windows_oneclick.ps1 | 41 ++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/scripts/build_windows_oneclick.ps1 b/scripts/build_windows_oneclick.ps1 index b5a69ce..4198a8f 100644 --- a/scripts/build_windows_oneclick.ps1 +++ b/scripts/build_windows_oneclick.ps1 @@ -266,6 +266,11 @@ Require-Path -PathValue $VenvPython -Label "Python du venv" Push-Location $ProjectRoot try { + # P1-7 (Plan 3) : version release unique, réutilisée par build_info.py, + # gui_v6/_build_version.py et l'installeur Inno Setup (/DAppVersion). + $ReleaseVersion = (Get-Date -Format "yyyy.MM.dd.HHmm") + Write-Host "Version release : $ReleaseVersion" + Write-Step "Installation des dépendances de build" & $VenvPython -m pip install --upgrade pip setuptools wheel if (-not $SkipRequirements) { @@ -273,6 +278,28 @@ try { } & $VenvPython -m pip install pyinstaller + if ($GuiV6) { + Write-Step "Purge torch/optimum du venv de build (P0-3, GUI V6 torch-free)" + # optimum[onnxruntime] (requirements.txt) tire torch en dépendance cœur ; + # la GUI V6 ne l'utilise jamais (NER = onnxruntime brut, OCR = OnnxTR). + # La spec legacy V5 garde torch : purge limitée au flavor GUI V6. + & $VenvPython -m pip uninstall -y torch torchvision optimum 2>$null + & $VenvPython -c "import importlib.util,sys; sys.exit(1 if importlib.util.find_spec('torch') else 0)" + if ($LASTEXITCODE -ne 0) { + throw "torch encore importable dans le venv de build : purge P0-3 échouée." + } + Write-Host "Venv de build torch-free : OK" + } + + Write-Step "Précache des poids OnnxTR (P0-4)" + # La spec PyInstaller raise FileNotFoundError si db_resnet50/crnn_vgg16_bn + # sont absents du cache : on les télécharge explicitement au lieu de + # dépendre du cache résiduel de la machine. + & $VenvPython -c "from onnxtr.models import ocr_predictor; ocr_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn'); print('Poids OnnxTR en cache : OK')" + if ($LASTEXITCODE -ne 0) { + throw "Précache OnnxTR échoué (réseau ? proxy ?) : le build frozen échouerait sur les poids manquants." + } + Write-Step "Génération de build_info.py" $commit = "local" $branch = "local" @@ -291,10 +318,21 @@ BUILD_DATE = "$buildDate" BUILD_COMMIT = "$commit" BUILD_BRANCH = "$branch" BUILD_FLAVOR = "$BuildFlavor" +BUILD_VERSION = "$ReleaseVersion" "@ Set-Content -Path $BuildInfoPath -Value $buildInfo -Encoding UTF8 Write-Host "Build info : $buildDate / $branch / $commit" + if ($GuiV6) { + $BuildVersionPath = Join-Path $ProjectRoot "gui_v6\_build_version.py" + $buildVersionContent = @" +"""Version release - généré automatiquement par build_windows_oneclick.ps1 (P1-7).""" +BUILD_VERSION = "$ReleaseVersion" +"@ + Set-Content -Path $BuildVersionPath -Value $buildVersionContent -Encoding UTF8 + Write-Host "gui_v6/_build_version.py : $ReleaseVersion" + } + Write-Step "Nettoyage des anciens artefacts" foreach ($PathValue in @($BuildDir, $DistDir, $PackageDir)) { if (Test-Path $PathValue) { @@ -367,8 +405,7 @@ Build : $innoCompiler = Resolve-InnoCompiler if ($innoCompiler) { Write-Host "Inno Setup Compiler : $innoCompiler" - $installerVersion = (Get-Date -Format "yyyy.MM.dd.HHmm") - & $innoCompiler "/DAppVersion=$installerVersion" $InstallerScriptPath + & $innoCompiler "/DAppVersion=$ReleaseVersion" $InstallerScriptPath if ($LASTEXITCODE -ne 0) { throw "Inno Setup a échoué avec le code $LASTEXITCODE." }