Refonte install.bat — plus de call/sous-routines, tout lineaire

- Supprime les call :LABEL qui faisaient crasher la console
- Tout en goto lineaire, plus stable en batch Windows
- Option 3 Reparer ajoutee
- Tests automatiques a chaque etape
- Messages [OK]/[ERREUR] visibles

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

View File

@@ -15,8 +15,6 @@ set "PYTHON_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHO
set "GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py" set "GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py"
set "GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.2/MinGit-2.47.1.2-64-bit.zip" set "GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.2/MinGit-2.47.1.2-64-bit.zip"
:: ============================================================
:: MENU PRINCIPAL
:: ============================================================ :: ============================================================
:MENU :MENU
cls cls
@@ -37,191 +35,13 @@ if "%CHOIX%"=="1" goto INSTALL
if "%CHOIX%"=="2" goto UPDATE if "%CHOIX%"=="2" goto UPDATE
if "%CHOIX%"=="3" goto REPAIR if "%CHOIX%"=="3" goto REPAIR
if "%CHOIX%"=="4" goto UNINSTALL if "%CHOIX%"=="4" goto UNINSTALL
if "%CHOIX%"=="5" goto END if "%CHOIX%"=="5" goto FIN
echo Choix invalide. echo Choix invalide.
timeout /t 2 >nul timeout /t 2 >nul
goto MENU goto MENU
:: ============================================================ :: ============================================================
:: FONCTIONS COMMUNES :: INSTALLATION COMPLETE
:: ============================================================
:: ---- 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
:: ============================================================ :: ============================================================
:INSTALL :INSTALL
cls cls
@@ -230,90 +50,167 @@ echo INSTALLATION de %APP_NAME%
echo ============================================================ echo ============================================================
echo. echo.
:: Verifier si deja installe
if exist "%APP_DIR%\main.py" ( if exist "%APP_DIR%\main.py" (
echo [!] L'application est deja installee dans : echo [!] Deja installe dans %INSTALL_DIR%
echo %INSTALL_DIR% set /p "REINSTALL=Reinstaller ? [O/N] : "
echo.
set /p "REINSTALL=Voulez-vous reinstaller ? [O/N] : "
if /i "!REINSTALL!" neq "O" goto MENU if /i "!REINSTALL!" neq "O" goto MENU
echo.
echo Suppression de l'ancienne installation...
rmdir /s /q "%APP_DIR%" 2>nul rmdir /s /q "%APP_DIR%" 2>nul
del "%EXE_PATH%" 2>nul del "%EXE_PATH%" 2>nul
) )
:: Creer les repertoires
echo [1/7] Creation des repertoires...
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp" if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp"
echo [OK] %INSTALL_DIR%
:: Git :: ---- GIT ----
echo. echo.
echo [2/7] Git... echo [1/7] Git...
call :SETUP_GIT set "GIT_CMD="
if not defined GIT_CMD ( where git >nul 2>&1 && set "GIT_CMD=git" && echo [OK] Git systeme && goto INSTALL_STEP2
echo [ERREUR FATALE] Git n'a pas pu etre installe. if exist "%INSTALL_DIR%\git\cmd\git.exe" set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe" && echo [OK] Git portable && goto INSTALL_STEP2
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' -UseBasicParsing"
if not exist "%INSTALL_DIR%\temp\git.zip" (
echo [ERREUR] Echec telechargement Git
pause
goto MENU
)
powershell -Command "Expand-Archive -Force '%INSTALL_DIR%\temp\git.zip' '%INSTALL_DIR%\git'"
del "%INSTALL_DIR%\temp\git.zip" 2>nul
if not exist "%INSTALL_DIR%\git\cmd\git.exe" (
echo [ERREUR] git.exe introuvable apres extraction
pause
goto MENU
)
set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
echo [OK] Git portable installe
:: ---- PYTHON ----
:INSTALL_STEP2
echo.
echo [2/7] Python...
set "PYTHON_CMD="
where python >nul 2>&1 && set "PYTHON_CMD=python" && echo [OK] Python systeme && goto INSTALL_STEP3
where py >nul 2>&1 && set "PYTHON_CMD=py" && echo [OK] py launcher && goto INSTALL_STEP3
if exist "%PYTHON_DIR%\python.exe" set "PYTHON_CMD=%PYTHON_DIR%\python.exe" && echo [OK] Python embarque && goto INSTALL_STEP3
echo Telechargement de Python %PYTHON_VERSION%...
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' -UseBasicParsing"
if not exist "%INSTALL_DIR%\temp\python.zip" (
echo [ERREUR] Echec telechargement Python
pause
goto MENU
)
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
dir "%PYTHON_DIR%" 2>nul
pause
goto MENU
)
:: Activer pip
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 [OK] Python %PYTHON_VERSION% installe
:: ---- PIP ----
:INSTALL_STEP3
echo.
echo [3/7] Pip...
"%PYTHON_CMD%" -m pip --version >nul 2>&1
if %ERRORLEVEL%==0 (
echo [OK] pip deja present
goto INSTALL_STEP4
)
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' -UseBasicParsing"
"%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
pause pause
goto MENU goto MENU
) )
:: Python :: ---- DEPENDANCES ----
:INSTALL_STEP4
echo. echo.
echo [3/7] Python... echo [4/7] Dependances Python...
call :SETUP_PYTHON "%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location PyQt6 pypdf reportlab pypdfium2
if not defined PYTHON_CMD ( echo.
echo [ERREUR FATALE] Python n'a pas pu etre installe. echo Verification...
pause "%PYTHON_CMD%" -c "import PyQt6; print(' [OK] PyQt6')" 2>nul || echo [MANQUANT] PyQt6
goto MENU "%PYTHON_CMD%" -c "import pypdf; print(' [OK] pypdf')" 2>nul || echo [MANQUANT] pypdf
) "%PYTHON_CMD%" -c "import reportlab; print(' [OK] reportlab')" 2>nul || echo [MANQUANT] reportlab
"%PYTHON_CMD%" -c "import pypdfium2; print(' [OK] pypdfium2')" 2>nul || echo [MANQUANT] pypdfium2
:: Pip :: ---- CODE SOURCE ----
echo. echo.
echo [4/7] Pip... echo [5/7] Code source...
call :SETUP_PIP
:: Dependances
echo.
echo [5/7] Dependances...
call :SETUP_DEPS
:: Code source
echo.
echo [6/7] Code source...
if exist "%APP_DIR%\.git" ( if exist "%APP_DIR%\.git" (
echo Mise a jour du code existant...
pushd "%APP_DIR%" pushd "%APP_DIR%"
"%GIT_CMD%" pull origin master 2>&1 "%GIT_CMD%" pull origin master
popd popd
) else ( ) else (
if exist "%APP_DIR%" rmdir /s /q "%APP_DIR%" if exist "%APP_DIR%" rmdir /s /q "%APP_DIR%"
echo Clonage depuis %GITEA_REPO%... "%GIT_CMD%" clone "%GITEA_REPO%" "%APP_DIR%"
"%GIT_CMD%" clone "%GITEA_REPO%" "%APP_DIR%" 2>&1
) )
if not exist "%APP_DIR%\main.py" ( if not exist "%APP_DIR%\main.py" (
echo [ERREUR] main.py introuvable apres clonage. echo [ERREUR] main.py introuvable
echo Verifiez l'acces a %GITEA_REPO%
pause pause
goto MENU goto MENU
) )
echo [OK] Code source telecharge. echo [OK] Code telecharge
:: Raccourcis :: ---- LANCEURS ----
echo. echo.
echo [7/7] Raccourcis et lanceurs... echo [6/7] Creation des lanceurs...
call :SETUP_SHORTCUTS
:: Test (
echo @echo off
echo cd /d "%APP_DIR%"
echo "%PYTHON_CMD%" main.py
echo if errorlevel 1 pause
) > "%INSTALL_DIR%\lancer.bat"
(
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"
:: Raccourci Bureau
powershell -Command "$s = (New-Object -COM WScript.Shell).CreateShortcut([Environment]::GetFolderPath('Desktop')+'\%SHORTCUT_NAME%.lnk'); $s.TargetPath='%LAUNCH_TARGET%'; $s.WorkingDirectory='%APP_DIR%'; $s.Description='%APP_NAME%'; $s.Save()"
echo [OK] Raccourci Bureau
:: Raccourci Menu Demarrer
powershell -Command "$s = (New-Object -COM WScript.Shell).CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\%SHORTCUT_NAME%.lnk'); $s.TargetPath='%LAUNCH_TARGET%'; $s.WorkingDirectory='%APP_DIR%'; $s.Description='%APP_NAME%'; $s.Save()"
echo [OK] Raccourci Menu Demarrer
:: ---- TEST ----
echo. echo.
echo [TEST] Verification de l'installation... echo [7/7] Test de l'application...
call :TEST_LAUNCH "%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"
)
:: Nettoyer temp :: Nettoyage
rmdir /s /q "%INSTALL_DIR%\temp" 2>nul rmdir /s /q "%INSTALL_DIR%\temp" 2>nul
:: Resume
echo. echo.
echo ============================================================ echo ============================================================
echo INSTALLATION TERMINEE echo INSTALLATION TERMINEE
@@ -322,9 +219,8 @@ echo.
echo Dossier : %INSTALL_DIR% echo Dossier : %INSTALL_DIR%
echo Python : %PYTHON_CMD% echo Python : %PYTHON_CMD%
echo. echo.
echo Pour lancer : raccourci Bureau "%SHORTCUT_NAME%" echo Lancer : raccourci Bureau "%SHORTCUT_NAME%"
echo Ou en ligne de commande : echo Debug : "%PYTHON_CMD%" "%APP_DIR%\main.py"
echo "%PYTHON_CMD%" "%APP_DIR%\main.py"
echo. echo.
echo Mot de passe requis au lancement. echo Mot de passe requis au lancement.
echo. echo.
@@ -342,61 +238,69 @@ echo ============================================================
echo. echo.
if not exist "%APP_DIR%\main.py" ( if not exist "%APP_DIR%\main.py" (
echo [!] L'application n'est pas installee. echo [!] Application non installee. Utilisez l'option 1.
echo Lancez d'abord l'installation (option 1).
echo.
pause pause
goto MENU goto MENU
) )
:: Detecter Git :: Trouver Git
echo [1/4] Detection de Git... set "GIT_CMD="
call :SETUP_GIT where git >nul 2>&1 && set "GIT_CMD=git"
if not defined GIT_CMD if exist "%INSTALL_DIR%\git\cmd\git.exe" set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe"
if not defined GIT_CMD ( if not defined GIT_CMD (
echo [ERREUR] Git introuvable. Utilisez l'option 3 (Reparer). echo [ERREUR] Git introuvable. Utilisez l'option 3 (Reparer).
pause pause
goto MENU goto MENU
) )
echo [OK] Git: %GIT_CMD%
:: Detecter Python :: Trouver Python
echo. set "PYTHON_CMD="
echo [2/4] Detection de Python... where python >nul 2>&1 && set "PYTHON_CMD=python"
call :SETUP_PYTHON if not defined PYTHON_CMD where py >nul 2>&1 && set "PYTHON_CMD=py"
if not defined PYTHON_CMD if exist "%PYTHON_DIR%\python.exe" set "PYTHON_CMD=%PYTHON_DIR%\python.exe"
if not defined PYTHON_CMD ( if not defined PYTHON_CMD (
echo [ERREUR] Python introuvable. Utilisez l'option 3 (Reparer). echo [ERREUR] Python introuvable. Utilisez l'option 3 (Reparer).
pause pause
goto MENU goto MENU
) )
echo [OK] Python: %PYTHON_CMD%
:: Mise a jour du code :: Pull
echo. echo.
echo [3/4] Mise a jour du code source... echo [1/3] Mise a jour du code...
pushd "%APP_DIR%" pushd "%APP_DIR%"
"%GIT_CMD%" fetch origin 2>&1 "%GIT_CMD%" fetch origin 2>&1
set "COMMITS=0"
for /f %%i in ('"%GIT_CMD%" rev-list HEAD..origin/master --count 2^>nul') do set "COMMITS=%%i" for /f %%i in ('"%GIT_CMD%" rev-list HEAD..origin/master --count 2^>nul') do set "COMMITS=%%i"
if "!COMMITS!"=="0" ( if "!COMMITS!"=="0" (
echo Deja a jour ! echo Deja a jour !
popd popd
) else (
echo !COMMITS! nouveau^(x^) commit^(s^) disponible^(s^):
echo. echo.
pause
goto MENU
)
echo !COMMITS! nouveau^(x^) commit^(s^):
"%GIT_CMD%" log --oneline HEAD..origin/master 2>nul "%GIT_CMD%" log --oneline HEAD..origin/master 2>nul
echo. echo.
"%GIT_CMD%" pull origin master 2>&1 "%GIT_CMD%" pull origin master
popd popd
echo [OK] Code mis a jour. echo [OK] Code mis a jour
)
:: Mise a jour dependances :: Deps
echo. echo.
echo [4/4] Mise a jour des dependances... echo [2/3] Mise a jour dependances...
call :SETUP_DEPS "%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location PyQt6 pypdf reportlab pypdfium2
:: Test :: Test
echo. echo.
echo [TEST] Verification... echo [3/3] Test...
call :TEST_LAUNCH "%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')"
if %ERRORLEVEL% neq 0 (
echo [ERREUR] Probleme detecte.
echo "%PYTHON_CMD%" "%APP_DIR%\main.py"
)
echo. echo.
echo ============================================================ echo ============================================================
@@ -415,57 +319,84 @@ echo ============================================================
echo REPARATION de %APP_NAME% echo REPARATION de %APP_NAME%
echo ============================================================ echo ============================================================
echo. echo.
echo Cette option reinstalle Python, pip et les dependances echo Reinstalle Python + pip + dependances
echo sans toucher au code source.
echo. echo.
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp"
:: Supprimer l'ancien Python embarque :: Supprimer ancien Python
echo [1/5] Nettoyage de l'ancien Python embarque... echo [1/4] Nettoyage ancien Python...
if exist "%PYTHON_DIR%" ( if exist "%PYTHON_DIR%" rmdir /s /q "%PYTHON_DIR%"
rmdir /s /q "%PYTHON_DIR%" 2>nul echo [OK]
echo Ancien Python supprime.
)
:: Reinstaller Python :: Python
echo. echo.
echo [2/5] Installation de Python... echo [2/4] Installation Python %PYTHON_VERSION%...
call :SETUP_PYTHON if not exist "%PYTHON_DIR%" mkdir "%PYTHON_DIR%"
if not defined PYTHON_CMD ( powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%PYTHON_URL%' -OutFile '%INSTALL_DIR%\temp\python.zip' -UseBasicParsing"
echo [ERREUR FATALE] Python n'a pas pu etre installe. if not exist "%INSTALL_DIR%\temp\python.zip" (
echo [ERREUR] Echec telechargement
pause pause
goto MENU goto MENU
) )
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
pause
goto MENU
)
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 [OK] Python installe
:: Pip :: Pip
echo. echo.
echo [3/5] Installation de pip... echo [3/4] Installation pip + dependances...
call :SETUP_PIP powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GET_PIP_URL%' -OutFile '%INSTALL_DIR%\temp\get-pip.py' -UseBasicParsing"
"%PYTHON_CMD%" "%INSTALL_DIR%\temp\get-pip.py" --no-warn-script-location
:: Dependances del "%INSTALL_DIR%\temp\get-pip.py" 2>nul
echo. "%PYTHON_CMD%" -m pip install --upgrade --no-warn-script-location PyQt6 pypdf reportlab pypdfium2
echo [4/5] Installation des dependances...
call :SETUP_DEPS
:: Test :: Test
echo. echo.
echo [5/5] Verification... echo [4/4] Verification...
call :TEST_LAUNCH "%PYTHON_CMD%" -c "import PyQt6; print(' [OK] PyQt6')" 2>nul || echo [MANQUANT] PyQt6
"%PYTHON_CMD%" -c "import pypdf; print(' [OK] pypdf')" 2>nul || echo [MANQUANT] pypdf
"%PYTHON_CMD%" -c "import reportlab; print(' [OK] reportlab')" 2>nul || echo [MANQUANT] reportlab
"%PYTHON_CMD%" -c "import pypdfium2; print(' [OK] pypdfium2')" 2>nul || echo [MANQUANT] pypdfium2
:: Recreer les lanceurs avec le bon chemin Python
if exist "%APP_DIR%\main.py" ( if exist "%APP_DIR%\main.py" (
echo. echo.
echo Mise a jour des lanceurs... "%PYTHON_CMD%" -c "import sys; sys.path.insert(0, r'%APP_DIR%'); from app.engine.pdf_utils import PAGE_SIZES; print(' [OK] Application prete')"
call :SETUP_SHORTCUTS
:: Mettre a jour les lanceurs
(
echo @echo off
echo cd /d "%APP_DIR%"
echo "%PYTHON_CMD%" main.py
echo if errorlevel 1 pause
) > "%INSTALL_DIR%\lancer.bat"
(
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"
echo [OK] Lanceurs mis a jour
) )
rmdir /s /q "%INSTALL_DIR%\temp" 2>nul
echo. echo.
echo ============================================================ echo ============================================================
echo REPARATION TERMINEE echo REPARATION TERMINEE
echo ============================================================ echo ============================================================
echo. echo.
echo Python : %PYTHON_CMD% echo Python : %PYTHON_CMD%
echo Debug : "%PYTHON_CMD%" "%APP_DIR%\main.py"
echo. echo.
pause pause
goto MENU goto MENU
@@ -481,43 +412,35 @@ echo ============================================================
echo. echo.
if not exist "%INSTALL_DIR%" ( if not exist "%INSTALL_DIR%" (
echo [!] L'application n'est pas installee. echo [!] Application non installee.
echo.
pause pause
goto MENU goto MENU
) )
echo Les elements suivants seront supprimes : echo Seront supprimes :
echo - %INSTALL_DIR%
echo - Raccourcis Bureau et Menu Demarrer
echo. echo.
echo - Dossier : %INSTALL_DIR% set /p "CONFIRM=Confirmer ? [O/N] : "
echo (code, Python embarque, Git portable)
echo - Raccourci Bureau
echo - Raccourci Menu Demarrer
echo.
set /p "CONFIRM=Confirmer la desinstallation ? [O/N] : "
if /i "%CONFIRM%" neq "O" goto MENU if /i "%CONFIRM%" neq "O" goto MENU
echo. echo.
echo [1/3] Suppression des raccourcis...
del "%USERPROFILE%\Desktop\%SHORTCUT_NAME%.lnk" 2>nul del "%USERPROFILE%\Desktop\%SHORTCUT_NAME%.lnk" 2>nul
del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\%SHORTCUT_NAME%.lnk" 2>nul del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\%SHORTCUT_NAME%.lnk" 2>nul
echo [OK] Raccourcis supprimes. echo [OK] Raccourcis supprimes
echo [2/3] Suppression des fichiers...
taskkill /f /im python.exe 2>nul taskkill /f /im python.exe 2>nul
taskkill /f /im pythonw.exe 2>nul
taskkill /f /im CopydevImposingTool.exe 2>nul taskkill /f /im CopydevImposingTool.exe 2>nul
timeout /t 2 >nul timeout /t 2 >nul
rmdir /s /q "%INSTALL_DIR%" 2>nul rmdir /s /q "%INSTALL_DIR%" 2>nul
if exist "%INSTALL_DIR%" ( if exist "%INSTALL_DIR%" (
echo [!] Certains fichiers n'ont pas pu etre supprimes. echo [!] Suppression incomplete. Supprimez manuellement :
echo Supprimez manuellement : %INSTALL_DIR% echo %INSTALL_DIR%
) else ( ) else (
echo [OK] Fichiers supprimes. echo [OK] Tout supprime
) )
echo [3/3] Desinstallation terminee.
echo. echo.
echo ============================================================ echo ============================================================
echo DESINSTALLATION TERMINEE echo DESINSTALLATION TERMINEE
@@ -527,8 +450,7 @@ pause
goto MENU goto MENU
:: ============================================================ :: ============================================================
:END :FIN
echo.
echo Au revoir ! echo Au revoir !
timeout /t 2 >nul timeout /t 2 >nul
exit /b 0 exit /b 0