From 16f30e8d382f642437c312f93e7bf7de0ab948cd Mon Sep 17 00:00:00 2001 From: Frank Conrads Date: Wed, 17 Jun 2026 10:46:39 +0200 Subject: [PATCH] install_and_run.bat to install svg-polish correctly in case of "new" standalone. Added requirements of packages in requirements-dev.txt and requirement.txt --- install_and_run.bat | 35 ++++++++++++++++++++++++++++++----- requirements-dev.txt | 3 +++ requirements.txt | 1 + 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 requirements-dev.txt create mode 100644 requirements.txt diff --git a/install_and_run.bat b/install_and_run.bat index 51afa91..9b070f4 100644 --- a/install_and_run.bat +++ b/install_and_run.bat @@ -12,7 +12,7 @@ set "SELF_DIR=%~dp0" set "SCRIPT=%SELF_DIR%pptx_image_compress.py" rem ---- Python Embeddable config ---- -set "PY_EMBED_VERSION=3.14.5" +set "PY_EMBED_VERSION=3.14.6" set "PY_EMBED_ZIP=python-%PY_EMBED_VERSION%-embed-amd64.zip" set "PY_EMBED_URL=https://www.python.org/ftp/python/%PY_EMBED_VERSION%/%PY_EMBED_ZIP%" set "PY_DIR=%SELF_DIR%python-embed" @@ -110,6 +110,14 @@ if errorlevel 1 ( ) set "PY_CMD=%PY_EXE%" +rem ---- Fix embedded Python isolation for the installation of pip ---- +set "PTH_FILE=%PY_DIR%\python314._pth" +if exist "%PTH_FILE%" ( + echo [INFO] Enabling site-packages in embedded Python... + powershell -Command ^ + "(Get-Content '%PTH_FILE%') -replace '^#?\s*import site','import site' | Set-Content '%PTH_FILE%'" +) + :have_python if not defined PY_CMD ( echo [ERROR] Konnte Python nicht ermitteln. Abbruch. @@ -122,8 +130,17 @@ if not exist "%SCRIPT%" ( exit /b 6 ) -set "RUN_ARGS=%*" -if "%~1"=="" set "RUN_ARGS=-h" +set "ALL_ARGS=%*" +set "RUN_ARGS=%ALL_ARGS%" +set "DEBUG_MODE=0" + +if "%~1"=="--debug" ( + set "DEBUG_MODE=1" + set "RUN_ARGS=!ALL_ARGS:~8!" + if "!RUN_ARGS:~0,1!"==" " set "RUN_ARGS=!RUN_ARGS:~1!" +) + +if "!RUN_ARGS!"=="" set "RUN_ARGS=-h" echo [INFO] Pruefe und installiere Python-Abhaengigkeit: svg-polish ... set "PIP_OK=0" @@ -165,14 +182,22 @@ if "%PIP_OK%"=="0" ( if "%PIP_OK%"=="1" ( if defined USE_PY_LAUNCHER ( - "%PY_CMD%" -3 -m pip install --disable-pip-version-check --quiet svg-polish + "%PY_CMD%" -3 -m pip install --disable-pip-version-check --quiet --no-warn-script-location svg-polish ) else ( - "%PY_CMD%" -m pip install --disable-pip-version-check --quiet svg-polish + "%PY_CMD%" -m pip install --disable-pip-version-check --quiet --no-warn-script-location svg-polish ) if errorlevel 1 ( echo [WARN] 'svg-polish' konnte nicht installiert werden. SVG-Dateien werden nicht komprimiert. ) else ( echo [OK] 'svg-polish' ist verfuegbar. + if %DEBUG_MODE%==1 ( + echo [DEBUG] pip list: + if defined USE_PY_LAUNCHER ( + "%PY_CMD%" -3 -m pip list + ) else ( + "%PY_CMD%" -m pip list + ) + ) ) ) else ( echo [WARN] pip konnte nicht eingerichtet werden. SVG-Dateien werden nicht komprimiert. diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..96813e0 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +svg-polish==1.0.0 +pytest==9.0.3 +pytest-cov==7.1.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..91b1520 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +svg-polish==1.0.0