From 3fa58cc73645b564db61ae41b847cf2a72b5e015 Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 20 Mar 2026 12:09:29 +0100 Subject: [PATCH] =?UTF-8?q?install.bat=20=E2=80=94=20menu=20Lancer,=20comp?= =?UTF-8?q?ilation=20.exe,=20raccourci=20Bureau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Option 4 "Lancer l'application" dans le menu - Compilation .exe PyInstaller en etape 8/8 de l'installation - Raccourci Bureau pointe vers le .exe si compilation OK - Proposé de lancer l'app en fin d'install/mise a jour Co-Authored-By: Claude Opus 4.6 (1M context) --- install.bat | 116 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 106 insertions(+), 10 deletions(-) diff --git a/install.bat b/install.bat index 4c1e84c..7981330 100644 --- a/install.bat +++ b/install.bat @@ -25,17 +25,19 @@ echo. echo 1. Installer echo 2. Mettre a jour echo 3. Reparer (reinstaller Python + dependances) -echo 4. Desinstaller -echo 5. Quitter +echo 4. Lancer l'application +echo 5. Desinstaller +echo 6. Quitter echo. set "CHOIX=" -set /p "CHOIX=Votre choix [1-5] : " +set /p "CHOIX=Votre choix [1-6] : " if "%CHOIX%"=="1" goto INSTALL if "%CHOIX%"=="2" goto UPDATE if "%CHOIX%"=="3" goto REPAIR -if "%CHOIX%"=="4" goto UNINSTALL -if "%CHOIX%"=="5" goto FIN +if "%CHOIX%"=="4" goto LAUNCH +if "%CHOIX%"=="5" goto UNINSTALL +if "%CHOIX%"=="6" goto FIN echo Choix invalide. timeout /t 2 >nul goto MENU @@ -223,12 +225,50 @@ echo [OK] Raccourci Menu Demarrer :: ---- TEST ---- echo. -echo [7/7] Test de l'application... +echo [7/8] Test de l'application... "%PYTHON_CMD%" -c "import sys; sys.path.insert(0, r'%APP_DIR%'); from app.engine.pdf_utils import PAGE_SIZES; print(' [OK] Moteur PDF charge avec', len(PAGE_SIZES), 'formats')" if %ERRORLEVEL% neq 0 ( echo [ERREUR] Le moteur PDF ne se charge pas - echo Lancez manuellement pour voir l'erreur : - echo "%PYTHON_CMD%" "%APP_DIR%\main.py" + echo Debug : "%PYTHON_CMD%" "%APP_DIR%\main.py" +) + +:: ---- COMPILATION EXE ---- +echo. +echo [8/8] Compilation de l'executable... +echo (peut prendre plusieurs minutes) +"%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location pyinstaller >nul 2>&1 +if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp" +pushd "%APP_DIR%" +"%PYTHON_CMD%" -m PyInstaller --onefile --noconsole --name CopydevImposingTool ^ + --add-data "resources;resources" ^ + --hidden-import pypdf ^ + --hidden-import reportlab ^ + --hidden-import reportlab.pdfgen ^ + --hidden-import reportlab.pdfgen.canvas ^ + --hidden-import reportlab.lib ^ + --hidden-import reportlab.lib.pagesizes ^ + --hidden-import reportlab.lib.units ^ + --hidden-import reportlab.lib.colors ^ + --hidden-import pypdfium2 ^ + --hidden-import pypdfium2._helpers ^ + --distpath "%INSTALL_DIR%" ^ + --workpath "%INSTALL_DIR%\temp\build" ^ + --specpath "%INSTALL_DIR%\temp" ^ + main.py 2>&1 | findstr /i "completed error" +popd + +if exist "%EXE_PATH%" ( + echo [OK] Executable compile : %EXE_PATH% + + :: Raccourci Bureau vers le .exe + powershell -Command "$s = (New-Object -COM WScript.Shell).CreateShortcut([Environment]::GetFolderPath('Desktop')+'\%SHORTCUT_NAME%.lnk'); $s.TargetPath='%EXE_PATH%'; $s.WorkingDirectory='%INSTALL_DIR%'; $s.Description='%APP_NAME%'; $s.Save()" + echo [OK] Raccourci Bureau pointe vers le .exe + + :: Raccourci Menu Demarrer vers le .exe + powershell -Command "$s = (New-Object -COM WScript.Shell).CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\%SHORTCUT_NAME%.lnk'); $s.TargetPath='%EXE_PATH%'; $s.WorkingDirectory='%INSTALL_DIR%'; $s.Description='%APP_NAME%'; $s.Save()" + echo [OK] Raccourci Menu Demarrer pointe vers le .exe +) else ( + echo [!] Compilation echouee, le raccourci utilise le lanceur Python ) :: Nettoyage @@ -240,13 +280,22 @@ echo INSTALLATION TERMINEE echo ============================================================ echo. echo Dossier : %INSTALL_DIR% -echo Python : %PYTHON_CMD% +if exist "%EXE_PATH%" ( + echo .exe : CopydevImposingTool.exe +) echo. echo Lancer : raccourci Bureau "%SHORTCUT_NAME%" -echo Debug : "%PYTHON_CMD%" "%APP_DIR%\main.py" echo. echo Mot de passe requis au lancement. echo. +set /p "LAUNCH=Lancer l'application maintenant ? [O/N] : " +if /i "!LAUNCH!"=="O" ( + if exist "%EXE_PATH%" ( + start "" "%EXE_PATH%" + ) else ( + start "" "%PYTHON_CMD%" "%APP_DIR%\main.py" + ) +) pause goto MENU @@ -379,6 +428,10 @@ echo. echo Lancer : raccourci Bureau "%SHORTCUT_NAME%" echo Debug : "%PYTHON_CMD%" "%APP_DIR%\main.py" echo. +set /p "LAUNCH2=Lancer l'application maintenant ? [O/N] : " +if /i "!LAUNCH2!"=="O" ( + start "" "%PYTHON_CMD%" "%APP_DIR%\main.py" +) pause goto MENU @@ -481,6 +534,49 @@ echo. pause goto MENU +:: ============================================================ +:: LANCER L'APPLICATION +:: ============================================================ +:LAUNCH +cls +echo ============================================================ +echo LANCEMENT de %APP_NAME% +echo ============================================================ +echo. + +if not exist "%APP_DIR%\main.py" ( + echo [!] Application non installee. Utilisez l'option 1. + pause + goto MENU +) + +:: Trouver Python +set "PYTHON_CMD=" +if exist "%PYTHON_DIR%\python.exe" ( + set "PYTHON_CMD=%PYTHON_DIR%\python.exe" +) else ( + where python >nul 2>&1 + if !ERRORLEVEL!==0 ( + set "PYTHON_CMD=python" + ) else ( + where py >nul 2>&1 + if !ERRORLEVEL!==0 set "PYTHON_CMD=py" + ) +) + +if not defined PYTHON_CMD ( + echo [ERREUR] Python introuvable. Utilisez l'option 3 ^(Reparer^). + pause + goto MENU +) + +echo Lancement en cours... +start "" "%PYTHON_CMD%" "%APP_DIR%\main.py" +echo. +echo Application lancee. +timeout /t 3 >nul +goto MENU + :: ============================================================ :: DESINSTALLATION :: ============================================================