129 lines
4.0 KiB
Batchfile
129 lines
4.0 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions
|
|
cd /d "%~dp0"
|
|
chcp 65001 >nul 2>&1
|
|
|
|
set "DO_PAUSE=1"
|
|
set "WANT_CLEAN=0"
|
|
set "FAST=0"
|
|
|
|
:parse_args
|
|
if "%~1"=="" goto :args_done
|
|
if /i "%~1"=="nopause" set "DO_PAUSE=0"
|
|
if /i "%~1"=="clean" set "WANT_CLEAN=1"
|
|
if /i "%~1"=="fast" set "FAST=1"
|
|
shift
|
|
goto :parse_args
|
|
:args_done
|
|
|
|
set "PYI_SPEC=md2gost.spec"
|
|
set "PYI_WORK="
|
|
set "PYI_DIST="
|
|
set "PYI_CLEAN=--clean"
|
|
if "%FAST%"=="1" (
|
|
set "PYI_SPEC=md2gost.fast.spec"
|
|
set "PYI_WORK=--workpath build-fast"
|
|
set "PYI_DIST=--distpath dist"
|
|
set "PYI_CLEAN="
|
|
if "%WANT_CLEAN%"=="1" set "PYI_CLEAN=--clean"
|
|
)
|
|
|
|
if "%FAST%"=="1" (
|
|
echo === md2gost: сборка exe через uvx, Python 3.11, fast spec ===
|
|
echo Spec: md2gost.fast.spec
|
|
echo Кэш: build-fast\
|
|
) else (
|
|
echo === md2gost: сборка exe через uvx, Python 3.11 ===
|
|
echo Spec: md2gost.spec
|
|
)
|
|
echo Каталог: %CD%
|
|
echo uvx сам возьмёт CPython 3.11 ^(скачает, если ещё нет^).
|
|
echo.
|
|
|
|
set "UVX_BIN="
|
|
for /f "delims=" %%I in ('where uvx 2^>nul') do (
|
|
set "UVX_BIN=%%I"
|
|
goto :got_uvx
|
|
)
|
|
if exist "%USERPROFILE%\.local\bin\uvx.exe" set "UVX_BIN=%USERPROFILE%\.local\bin\uvx.exe"
|
|
if defined UVX_BIN goto :got_uvx
|
|
if exist "%USERPROFILE%\.cargo\bin\uvx.exe" set "UVX_BIN=%USERPROFILE%\.cargo\bin\uvx.exe"
|
|
if defined UVX_BIN goto :got_uvx
|
|
|
|
echo uvx не найден. Установите uv: https://docs.astral.sh/uv/getting-started/installation/
|
|
echo powershell: irm https://astral.sh/uv/install.ps1 ^| iex
|
|
goto :fail
|
|
|
|
:got_uvx
|
|
echo uvx: %UVX_BIN%
|
|
"%UVX_BIN%" --python 3.11 python -c "import sys; print('CPython', sys.version.split()[0], sys.executable)"
|
|
if errorlevel 1 goto :nopython
|
|
|
|
if not exist "md2gost\Template.docx" goto :notemplate
|
|
|
|
echo [1/4] PlantUML jar + Graphviz + Mermaid assets ...
|
|
"%UVX_BIN%" --python 3.11 --isolated --with-editable . -- python scripts\fetch_plantuml.py
|
|
if "%FAST%"=="1" (
|
|
if not exist "md2gost\vendor\plantuml.jar" goto :nojar
|
|
) else (
|
|
if not exist "md2gost\vendor\plantuml.jar" (
|
|
echo Предупреждение: plantuml.jar нет — в exe UML пойдёт через kroki.io.
|
|
)
|
|
)
|
|
"%UVX_BIN%" --python 3.11 --isolated --with-editable . -- python scripts\fetch_graphviz.py
|
|
if not exist "md2gost\vendor\graphviz\bin\dot.exe" (
|
|
echo Предупреждение: Graphviz нет — в exe DFD пойдёт через kroki.io / PATH.
|
|
)
|
|
if not exist "md2gost\diagrams\mermaid.min.js" (
|
|
"%UVX_BIN%" --python 3.11 --isolated --with-editable . -- python scripts\fetch_mermaid.py
|
|
)
|
|
if "%FAST%"=="0" (
|
|
if not exist "md2gost\diagrams\mermaid.min.js" (
|
|
echo Предупреждение: mermaid.min.js нет — браузерный Mermaid в exe без assets.
|
|
)
|
|
)
|
|
|
|
echo [2/4] Эфемерное окружение: проект + matplotlib + PyInstaller ^(CPython 3.11^) ...
|
|
echo [3/4] PyInstaller, один файл ...
|
|
"%UVX_BIN%" --python 3.11 --isolated --from "pyinstaller>=6.0" --with-editable . --with "matplotlib>=3.7" --with "tkinterdnd2" -- pyinstaller --noconfirm %PYI_CLEAN% %PYI_WORK% %PYI_DIST% %PYI_SPEC%
|
|
if errorlevel 1 goto :pyifail
|
|
|
|
if not exist "dist\md2gost.exe" goto :noexe
|
|
|
|
echo.
|
|
echo [4/4] Готово:
|
|
echo %CD%\dist\md2gost.exe
|
|
echo.
|
|
echo Двойной клик — GUI. Из консоли: md2gost.exe report.md -o report.docx
|
|
echo Быстрый кэш: build-exe-uvx.bat fast
|
|
echo Полный пересбор fast: build-exe-uvx.bat fast clean
|
|
echo.
|
|
if "%DO_PAUSE%"=="1" pause
|
|
exit /b 0
|
|
|
|
:nopython
|
|
echo uvx не смог запустить Python 3.11.
|
|
goto :fail
|
|
|
|
:notemplate
|
|
echo Нет md2gost\Template.docx — сборка бессмысленна.
|
|
goto :fail
|
|
|
|
:nojar
|
|
echo Нет md2gost\vendor\plantuml.jar — portable exe без jar не собираем.
|
|
goto :fail
|
|
|
|
:pyifail
|
|
echo PyInstaller завершился с ошибкой.
|
|
goto :fail
|
|
|
|
:noexe
|
|
echo dist\md2gost.exe не появился.
|
|
goto :fail
|
|
|
|
:fail
|
|
echo.
|
|
echo Сборка не удалась.
|
|
if "%DO_PAUSE%"=="1" pause
|
|
exit /b 1
|