Refonte complete install.bat — debug, reparation, tests

- Chaque etape affiche [OK] ou [ERREUR] avec details
- Messages PowerShell visibles (plus de >/dev/null sur les telecharger)
- Option 3 "Reparer" : reinstalle Python/pip/deps sans toucher au code
- Test automatique apres install/update : verifie imports Python
- Affiche la commande pour lancer en ligne de commande (debug)
- Fallback py launcher (py --version) en plus de python
- Verification taille fichier telecharge

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jules
2026-03-20 11:40:29 +01:00
parent 785a7d183a
commit e116cf21a5

View File

@@ -7,6 +7,7 @@ set "APP_NAME=Copydev Imposing Tool"
set "INSTALL_DIR=%LOCALAPPDATA%\CopydevImposingTool"
set "PYTHON_DIR=%INSTALL_DIR%\python"
set "APP_DIR=%INSTALL_DIR%\app"
set "EXE_PATH=%INSTALL_DIR%\CopydevImposingTool.exe"
set "SHORTCUT_NAME=Copydev Imposing Tool"
set "GITEA_REPO=https://git.copydev.fr/jules/copydev-imposing-tool.git"
set "PYTHON_VERSION=3.12.8"
@@ -25,19 +26,200 @@ echo ============================================================
echo.
echo 1. Installer
echo 2. Mettre a jour
echo 3. Desinstaller
echo 4. Quitter
echo 3. Reparer (reinstaller Python + dependances)
echo 4. Desinstaller
echo 5. Quitter
echo.
set /p "CHOIX=Votre choix [1-4] : "
set "CHOIX="
set /p "CHOIX=Votre choix [1-5] : "
if "%CHOIX%"=="1" goto INSTALL
if "%CHOIX%"=="2" goto UPDATE
if "%CHOIX%"=="3" goto UNINSTALL
if "%CHOIX%"=="4" goto END
if "%CHOIX%"=="3" goto REPAIR
if "%CHOIX%"=="4" goto UNINSTALL
if "%CHOIX%"=="5" goto END
echo Choix invalide.
timeout /t 2 >nul
goto MENU
:: ============================================================
:: FONCTIONS COMMUNES
:: ============================================================
:: ---- Detecter ou installer Git ----
:SETUP_GIT
where git >nul 2>&1
if %ERRORLEVEL%==0 (
echo [OK] Git systeme detecte.
set "GIT_CMD=git"
goto :EOF
)
if exist "%INSTALL_DIR%\git\cmd\git.exe" (
echo [OK] Git portable detecte.
set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
goto :EOF
)
echo Telechargement de Git portable...
if not exist "%INSTALL_DIR%\git" mkdir "%INSTALL_DIR%\git"
if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp"
echo URL: %GIT_URL%
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%INSTALL_DIR%\temp\git.zip' -UseBasicParsing }"
if not exist "%INSTALL_DIR%\temp\git.zip" (
echo [ERREUR] Echec du telechargement de Git.
set "GIT_CMD="
goto :EOF
)
echo Extraction...
powershell -Command "Expand-Archive -Force '%INSTALL_DIR%\temp\git.zip' '%INSTALL_DIR%\git'"
del "%INSTALL_DIR%\temp\git.zip" 2>nul
if exist "%INSTALL_DIR%\git\cmd\git.exe" (
echo [OK] Git portable installe.
set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
) else (
echo [ERREUR] Git n'a pas ete extrait correctement.
set "GIT_CMD="
)
goto :EOF
:: ---- Detecter ou installer Python ----
:SETUP_PYTHON
:: Python systeme ?
where python >nul 2>&1
if %ERRORLEVEL%==0 (
for /f "tokens=*" %%i in ('python --version 2^>^&1') do echo [OK] %%i detecte.
set "PYTHON_CMD=python"
goto :EOF
)
:: py launcher ?
where py >nul 2>&1
if %ERRORLEVEL%==0 (
for /f "tokens=*" %%i in ('py --version 2^>^&1') do echo [OK] %%i detecte.
set "PYTHON_CMD=py"
goto :EOF
)
:: Python embarque deja installe ?
if exist "%PYTHON_DIR%\python.exe" (
echo [OK] Python embarque detecte.
set "PYTHON_CMD=%PYTHON_DIR%\python.exe"
goto :EOF
)
:: Installer Python embarque
echo Telechargement de Python %PYTHON_VERSION%...
if not exist "%PYTHON_DIR%" mkdir "%PYTHON_DIR%"
if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp"
echo URL: %PYTHON_URL%
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%PYTHON_URL%' -OutFile '%INSTALL_DIR%\temp\python.zip' -UseBasicParsing }"
if not exist "%INSTALL_DIR%\temp\python.zip" (
echo [ERREUR] Echec du telechargement de Python.
set "PYTHON_CMD="
goto :EOF
)
for %%A in ("%INSTALL_DIR%\temp\python.zip") do echo Fichier telecharge: %%~zA octets
echo Extraction...
powershell -Command "Expand-Archive -Force '%INSTALL_DIR%\temp\python.zip' '%PYTHON_DIR%'"
del "%INSTALL_DIR%\temp\python.zip" 2>nul
if not exist "%PYTHON_DIR%\python.exe" (
echo [ERREUR] python.exe introuvable apres extraction.
echo Contenu du dossier:
dir "%PYTHON_DIR%" 2>nul
set "PYTHON_CMD="
goto :EOF
)
:: Activer pip (decommenter import site dans le fichier ._pth)
for %%f in ("%PYTHON_DIR%\python*._pth") do (
echo Activation pip dans %%~nxf...
powershell -Command "(Get-Content '%%f') -replace '#import site','import site' | Set-Content '%%f'"
)
echo [OK] Python %PYTHON_VERSION% installe.
set "PYTHON_CMD=%PYTHON_DIR%\python.exe"
goto :EOF
:: ---- Installer pip ----
:SETUP_PIP
"%PYTHON_CMD%" -m pip --version >nul 2>&1
if %ERRORLEVEL%==0 (
echo [OK] pip deja installe.
goto :EOF
)
echo Telechargement de pip...
if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp"
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GET_PIP_URL%' -OutFile '%INSTALL_DIR%\temp\get-pip.py' -UseBasicParsing }"
if not exist "%INSTALL_DIR%\temp\get-pip.py" (
echo [ERREUR] Echec du telechargement de get-pip.py
goto :EOF
)
echo Installation de pip...
"%PYTHON_CMD%" "%INSTALL_DIR%\temp\get-pip.py" --no-warn-script-location
del "%INSTALL_DIR%\temp\get-pip.py" 2>nul
"%PYTHON_CMD%" -m pip --version >nul 2>&1
if %ERRORLEVEL%==0 (
echo [OK] pip installe.
) else (
echo [ERREUR] pip n'a pas pu etre installe.
)
goto :EOF
:: ---- Installer dependances ----
:SETUP_DEPS
echo Installation des dependances...
"%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location PyQt6 pypdf reportlab pypdfium2 2>&1
echo.
:: Verification
echo Verification des dependances...
"%PYTHON_CMD%" -c "import PyQt6; print(' [OK] PyQt6')" 2>nul || echo [ERREUR] PyQt6 manquant
"%PYTHON_CMD%" -c "import pypdf; print(' [OK] pypdf')" 2>nul || echo [ERREUR] pypdf manquant
"%PYTHON_CMD%" -c "import reportlab; print(' [OK] reportlab')" 2>nul || echo [ERREUR] reportlab manquant
"%PYTHON_CMD%" -c "import pypdfium2; print(' [OK] pypdfium2')" 2>nul || echo [ERREUR] pypdfium2 manquant
goto :EOF
:: ---- Creer lanceur et raccourcis ----
:SETUP_SHORTCUTS
:: Lanceur .bat (avec console pour voir les erreurs)
(
echo @echo off
echo cd /d "%APP_DIR%"
echo "%PYTHON_CMD%" main.py
echo if errorlevel 1 pause
) > "%INSTALL_DIR%\lancer.bat"
:: Lanceur .vbs (sans console)
(
echo Set WshShell = CreateObject^("WScript.Shell"^)
echo WshShell.CurrentDirectory = "%APP_DIR%"
echo WshShell.Run """%PYTHON_CMD%"" ""%APP_DIR%\main.py""", 0, False
) > "%INSTALL_DIR%\lancer.vbs"
:: Determiner la cible du raccourci
if exist "%EXE_PATH%" (
set "LAUNCH_TARGET=%EXE_PATH%"
) else (
set "LAUNCH_TARGET=%INSTALL_DIR%\lancer.vbs"
)
:: Raccourci Bureau
powershell -Command "& { $WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut([Environment]::GetFolderPath('Desktop') + '\%SHORTCUT_NAME%.lnk'); $Shortcut.TargetPath = '!LAUNCH_TARGET!'; $Shortcut.WorkingDirectory = '%APP_DIR%'; $Shortcut.Description = '%APP_NAME%'; $Shortcut.Save() }" 2>nul
echo [OK] Raccourci Bureau cree.
:: Raccourci Menu Demarrer
set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs"
powershell -Command "& { $WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%START_MENU%\%SHORTCUT_NAME%.lnk'); $Shortcut.TargetPath = '!LAUNCH_TARGET!'; $Shortcut.WorkingDirectory = '%APP_DIR%'; $Shortcut.Description = '%APP_NAME%'; $Shortcut.Save() }" 2>nul
echo [OK] Raccourci Menu Demarrer cree.
goto :EOF
:: ---- Test de lancement ----
:TEST_LAUNCH
echo.
echo --- Test de lancement ---
"%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'); print(' Tailles:', ', '.join(PAGE_SIZES.keys()))" 2>&1
if %ERRORLEVEL% neq 0 (
echo [ERREUR] Le moteur PDF ne se charge pas correctement.
echo Tentative de diagnostic...
"%PYTHON_CMD%" -c "import sys; sys.path.insert(0, r'%APP_DIR%'); import app" 2>&1
) else (
echo [OK] Application prete.
)
goto :EOF
:: ============================================================
:: INSTALLATION
:: ============================================================
@@ -49,7 +231,7 @@ echo ============================================================
echo.
:: Verifier si deja installe
if exist "%INSTALL_DIR%\app\main.py" (
if exist "%APP_DIR%\main.py" (
echo [!] L'application est deja installee dans :
echo %INSTALL_DIR%
echo.
@@ -58,110 +240,48 @@ if exist "%INSTALL_DIR%\app\main.py" (
echo.
echo Suppression de l'ancienne installation...
rmdir /s /q "%APP_DIR%" 2>nul
del "%EXE_PATH%" 2>nul
)
:: Creer le repertoire d'installation
set "EXE_PATH=%INSTALL_DIR%\CopydevImposingTool.exe"
echo [1/8] Creation du repertoire d'installation...
:: Creer les repertoires
echo [1/7] Creation des repertoires...
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp"
echo [OK] %INSTALL_DIR%
:: ---- GIT ----
:INSTALL_GIT
echo [2/8] Verification de Git...
where git >nul 2>&1
if %ERRORLEVEL%==0 (
echo Git est deja installe.
set "GIT_CMD=git"
goto INSTALL_PYTHON
)
:: Git portable
if exist "%INSTALL_DIR%\git\cmd\git.exe" (
echo Git portable detecte.
set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
goto INSTALL_PYTHON
)
echo Telechargement de Git portable...
if not exist "%INSTALL_DIR%\git" mkdir "%INSTALL_DIR%\git"
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%INSTALL_DIR%\temp\git.zip' }" 2>nul
if not exist "%INSTALL_DIR%\temp\git.zip" (
echo [ERREUR] Impossible de telecharger Git.
echo Verifiez votre connexion internet.
:: Git
echo.
echo [2/7] Git...
call :SETUP_GIT
if not defined GIT_CMD (
echo [ERREUR FATALE] Git n'a pas pu etre installe.
pause
goto MENU
)
echo Extraction de Git...
powershell -Command "Expand-Archive -Force '%INSTALL_DIR%\temp\git.zip' '%INSTALL_DIR%\git'" 2>nul
del "%INSTALL_DIR%\temp\git.zip" 2>nul
set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
echo Git portable installe.
:: ---- PYTHON ----
:INSTALL_PYTHON
echo [3/8] Verification de Python...
:: Verifier Python systeme
where python >nul 2>&1
if %ERRORLEVEL%==0 (
for /f "tokens=*" %%i in ('python --version 2^>^&1') do set "PY_VER=%%i"
echo !PY_VER! detecte.
set "PYTHON_CMD=python"
goto INSTALL_PIP
)
:: Python embarque
if exist "%PYTHON_DIR%\python.exe" (
echo Python embarque detecte.
set "PYTHON_CMD=%PYTHON_DIR%\python.exe"
goto INSTALL_PIP
)
echo Telechargement de Python %PYTHON_VERSION% embarque...
if not exist "%PYTHON_DIR%" mkdir "%PYTHON_DIR%"
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%PYTHON_URL%' -OutFile '%INSTALL_DIR%\temp\python.zip' }" 2>nul
if not exist "%INSTALL_DIR%\temp\python.zip" (
echo [ERREUR] Impossible de telecharger Python.
:: Python
echo.
echo [3/7] Python...
call :SETUP_PYTHON
if not defined PYTHON_CMD (
echo [ERREUR FATALE] Python n'a pas pu etre installe.
pause
goto MENU
)
echo Extraction de Python...
powershell -Command "Expand-Archive -Force '%INSTALL_DIR%\temp\python.zip' '%PYTHON_DIR%'" 2>nul
del "%INSTALL_DIR%\temp\python.zip" 2>nul
:: Activer pip dans Python embarque (decommenter import site)
for %%f in ("%PYTHON_DIR%\python*._pth") do (
powershell -Command "(Get-Content '%%f') -replace '#import site','import site' | Set-Content '%%f'"
)
set "PYTHON_CMD=%PYTHON_DIR%\python.exe"
echo Python %PYTHON_VERSION% embarque installe.
:: Pip
echo.
echo [4/7] Pip...
call :SETUP_PIP
:: ---- PIP ----
:INSTALL_PIP
echo [4/8] Verification de pip...
"%PYTHON_CMD%" -m pip --version >nul 2>&1
if %ERRORLEVEL%==0 (
echo pip est deja installe.
goto INSTALL_DEPS
)
:: Dependances
echo.
echo [5/7] Dependances...
call :SETUP_DEPS
echo Installation de pip...
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GET_PIP_URL%' -OutFile '%INSTALL_DIR%\temp\get-pip.py' }" 2>nul
"%PYTHON_CMD%" "%INSTALL_DIR%\temp\get-pip.py" --no-warn-script-location >nul 2>&1
del "%INSTALL_DIR%\temp\get-pip.py" 2>nul
echo pip installe.
:: ---- DEPENDANCES ----
:INSTALL_DEPS
echo [5/8] Installation des dependances Python...
"%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location PyQt6 pypdf reportlab pypdfium2 pyinstaller 2>&1 | findstr /i "Successfully already"
echo Dependances installees.
:: ---- CODE SOURCE ----
:INSTALL_CODE
echo [6/8] Telechargement du code source...
:: Code source
echo.
echo [6/7] Code source...
if exist "%APP_DIR%\.git" (
echo Mise a jour du code existant...
pushd "%APP_DIR%"
@@ -169,84 +289,42 @@ if exist "%APP_DIR%\.git" (
popd
) else (
if exist "%APP_DIR%" rmdir /s /q "%APP_DIR%"
echo Clonage depuis %GITEA_REPO%...
"%GIT_CMD%" clone "%GITEA_REPO%" "%APP_DIR%" 2>&1
)
if not exist "%APP_DIR%\main.py" (
echo [ERREUR] Le telechargement du code a echoue.
echo [ERREUR] main.py introuvable apres clonage.
echo Verifiez l'acces a %GITEA_REPO%
pause
goto MENU
)
echo Code source telecharge.
echo [OK] Code source telecharge.
:: ---- COMPILATION EXE ----
:INSTALL_BUILD
echo [7/8] Compilation de l'executable...
echo (cette etape peut prendre quelques minutes)
pushd "%APP_DIR%"
"%PYTHON_CMD%" -m PyInstaller --onefile --noconsole --name CopydevImposingTool ^
--icon "%APP_DIR%\resources\logo.png" ^
--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 >nul 2>&1
popd
:: Raccourcis
echo.
echo [7/7] Raccourcis et lanceurs...
call :SETUP_SHORTCUTS
if not exist "%EXE_PATH%" (
echo [!] La compilation a echoue. Utilisation du lanceur Python.
:: Fallback : lanceur .vbs
(
echo Set WshShell = CreateObject^("WScript.Shell"^)
echo WshShell.CurrentDirectory = "%APP_DIR%"
echo WshShell.Run """%PYTHON_CMD%"" ""%APP_DIR%\main.py""", 0, False
) > "%INSTALL_DIR%\lancer.vbs"
set "LAUNCH_TARGET=%INSTALL_DIR%\lancer.vbs"
set "LAUNCH_ICON="
) else (
echo Executable compile : CopydevImposingTool.exe
set "LAUNCH_TARGET=%EXE_PATH%"
set "LAUNCH_ICON=%EXE_PATH%"
)
:: Test
echo.
echo [TEST] Verification de l'installation...
call :TEST_LAUNCH
:: ---- RACCOURCIS ----
:INSTALL_SHORTCUTS
echo [8/8] Creation des raccourcis...
:: Raccourci Bureau
powershell -Command "& { $WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut([Environment]::GetFolderPath('Desktop') + '\%SHORTCUT_NAME%.lnk'); $Shortcut.TargetPath = '%LAUNCH_TARGET%'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = '%APP_NAME%'; if ('%LAUNCH_ICON%' -ne '') { $Shortcut.IconLocation = '%LAUNCH_ICON%,0' }; $Shortcut.Save() }" 2>nul
echo Raccourci Bureau cree.
:: Raccourci Menu Demarrer
set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs"
powershell -Command "& { $WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%START_MENU%\%SHORTCUT_NAME%.lnk'); $Shortcut.TargetPath = '%LAUNCH_TARGET%'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = '%APP_NAME%'; if ('%LAUNCH_ICON%' -ne '') { $Shortcut.IconLocation = '%LAUNCH_ICON%,0' }; $Shortcut.Save() }" 2>nul
echo Raccourci Menu Demarrer cree.
:: Nettoyer temp et fichiers de build
:: Nettoyer temp
rmdir /s /q "%INSTALL_DIR%\temp" 2>nul
:: ---- FIN INSTALLATION ----
:: Resume
echo.
echo ============================================================
echo INSTALLATION TERMINEE
echo ============================================================
echo.
echo Dossier : %INSTALL_DIR%
if exist "%EXE_PATH%" (
echo Executable: CopydevImposingTool.exe
)
echo Lanceur : Raccourci Bureau ou Menu Demarrer
echo "%SHORTCUT_NAME%"
echo Python : %PYTHON_CMD%
echo.
echo Pour lancer : raccourci Bureau "%SHORTCUT_NAME%"
echo Ou en ligne de commande :
echo "%PYTHON_CMD%" "%APP_DIR%\main.py"
echo.
echo Mot de passe requis au lancement.
echo.
@@ -265,87 +343,61 @@ echo.
if not exist "%APP_DIR%\main.py" (
echo [!] L'application n'est pas installee.
echo Lancez d'abord l'installation.
echo Lancez d'abord l'installation (option 1).
echo.
pause
goto MENU
)
:: Determiner Git
where git >nul 2>&1
if %ERRORLEVEL%==0 (
set "GIT_CMD=git"
) else if exist "%INSTALL_DIR%\git\cmd\git.exe" (
set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
) else (
echo [ERREUR] Git introuvable. Reinstallez l'application.
:: Detecter Git
echo [1/4] Detection de Git...
call :SETUP_GIT
if not defined GIT_CMD (
echo [ERREUR] Git introuvable. Utilisez l'option 3 (Reparer).
pause
goto MENU
)
:: Determiner Python
where python >nul 2>&1
if %ERRORLEVEL%==0 (
set "PYTHON_CMD=python"
) else if exist "%PYTHON_DIR%\python.exe" (
set "PYTHON_CMD=%PYTHON_DIR%\python.exe"
) else (
echo [ERREUR] Python introuvable. Reinstallez l'application.
:: Detecter Python
echo.
echo [2/4] Detection de Python...
call :SETUP_PYTHON
if not defined PYTHON_CMD (
echo [ERREUR] Python introuvable. Utilisez l'option 3 (Reparer).
pause
goto MENU
)
echo [1/3] Mise a jour du code source...
:: Mise a jour du code
echo.
echo [3/4] Mise a jour du code source...
pushd "%APP_DIR%"
"%GIT_CMD%" fetch origin 2>&1
:: Afficher les changements
for /f %%i in ('"%GIT_CMD%" rev-list HEAD..origin/master --count 2^>nul') do set "COMMITS=%%i"
if "!COMMITS!"=="0" (
echo Deja a jour !
popd
echo.
pause
goto MENU
)
echo !COMMITS! nouveau(x) commit(s) disponible(s).
"%GIT_CMD%" log --oneline HEAD..origin/master 2>nul
echo.
"%GIT_CMD%" pull origin master 2>&1
popd
echo Code mis a jour.
echo [2/4] Mise a jour des dependances...
"%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location PyQt6 pypdf reportlab pypdfium2 pyinstaller 2>&1 | findstr /i "Successfully already"
echo [3/4] Recompilation de l'executable...
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 >nul 2>&1
popd
rmdir /s /q "%INSTALL_DIR%\temp" 2>nul
if exist "%INSTALL_DIR%\CopydevImposingTool.exe" (
echo Executable recompile.
) else (
echo [!] Compilation echouee, l'ancienne version reste active.
echo !COMMITS! nouveau^(x^) commit^(s^) disponible^(s^):
echo.
"%GIT_CMD%" log --oneline HEAD..origin/master 2>nul
echo.
"%GIT_CMD%" pull origin master 2>&1
popd
echo [OK] Code mis a jour.
)
echo [4/4] Termine !
:: Mise a jour dependances
echo.
echo [4/4] Mise a jour des dependances...
call :SETUP_DEPS
:: Test
echo.
echo [TEST] Verification...
call :TEST_LAUNCH
echo.
echo ============================================================
echo MISE A JOUR TERMINEE
@@ -354,6 +406,70 @@ echo.
pause
goto MENU
:: ============================================================
:: REPARATION
:: ============================================================
:REPAIR
cls
echo ============================================================
echo REPARATION de %APP_NAME%
echo ============================================================
echo.
echo Cette option reinstalle Python, pip et les dependances
echo sans toucher au code source.
echo.
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
:: Supprimer l'ancien Python embarque
echo [1/5] Nettoyage de l'ancien Python embarque...
if exist "%PYTHON_DIR%" (
rmdir /s /q "%PYTHON_DIR%" 2>nul
echo Ancien Python supprime.
)
:: Reinstaller Python
echo.
echo [2/5] Installation de Python...
call :SETUP_PYTHON
if not defined PYTHON_CMD (
echo [ERREUR FATALE] Python n'a pas pu etre installe.
pause
goto MENU
)
:: Pip
echo.
echo [3/5] Installation de pip...
call :SETUP_PIP
:: Dependances
echo.
echo [4/5] Installation des dependances...
call :SETUP_DEPS
:: Test
echo.
echo [5/5] Verification...
call :TEST_LAUNCH
:: Recreer les lanceurs avec le bon chemin Python
if exist "%APP_DIR%\main.py" (
echo.
echo Mise a jour des lanceurs...
call :SETUP_SHORTCUTS
)
echo.
echo ============================================================
echo REPARATION TERMINEE
echo ============================================================
echo.
echo Python : %PYTHON_CMD%
echo.
pause
goto MENU
:: ============================================================
:: DESINSTALLATION
:: ============================================================
@@ -385,12 +501,12 @@ echo.
echo [1/3] Suppression des raccourcis...
del "%USERPROFILE%\Desktop\%SHORTCUT_NAME%.lnk" 2>nul
del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\%SHORTCUT_NAME%.lnk" 2>nul
echo Raccourcis supprimes.
echo [OK] Raccourcis supprimes.
echo [2/3] Suppression des fichiers...
:: Tuer les processus Python potentiellement en cours
taskkill /f /im python.exe 2>nul
taskkill /f /im pythonw.exe 2>nul
taskkill /f /im CopydevImposingTool.exe 2>nul
timeout /t 2 >nul
rmdir /s /q "%INSTALL_DIR%" 2>nul
@@ -398,7 +514,7 @@ if exist "%INSTALL_DIR%" (
echo [!] Certains fichiers n'ont pas pu etre supprimes.
echo Supprimez manuellement : %INSTALL_DIR%
) else (
echo Fichiers supprimes.
echo [OK] Fichiers supprimes.
)
echo [3/3] Desinstallation terminee.