Files
haha/build_exe_simple.bat
2026-01-16 12:56:08 +08:00

73 lines
1.7 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 65001 >nul
echo ========================================
echo 简单打包脚本 - 打包GUI程序为EXE
echo ========================================
echo.
REM 检查并安装PyInstaller
python -c "import PyInstaller" 2>nul
if errorlevel 1 (
echo [1/3] 正在安装PyInstaller...
pip install pyinstaller
if errorlevel 1 (
echo 安装失败,请手动运行: pip install pyinstaller
pause
exit /b 1
)
)
echo.
echo [2/3] 开始打包程序...
echo.
REM 清理之前的打包文件
if exist "dist" rmdir /s /q "dist"
if exist "build" rmdir /s /q "build"
if exist "发布配置工具.spec" del /q "发布配置工具.spec"
REM 打包命令
pyinstaller --name="发布配置工具" --onefile --windowed --add-data "main.py;." config_gui.py
if errorlevel 1 (
echo.
echo ========================================
echo 打包失败!请检查错误信息
echo ========================================
pause
exit /b 1
)
echo.
echo [3/3] 检查打包结果...
echo.
REM 检查EXE文件是否存在
if exist "dist\发布配置工具.exe" (
echo ========================================
echo 打包成功!
echo ========================================
echo.
echo EXE文件位置: %CD%\dist\发布配置工具.exe
echo.
echo 文件大小:
dir "dist\发布配置工具.exe" | find "发布配置工具.exe"
echo.
echo 提示: 首次运行可能需要几秒钟解压
echo.
) else (
echo ========================================
echo 打包失败未找到EXE文件
echo ========================================
pause
exit /b 1
)
echo 是否现在打开dist文件夹(Y/N)
set /p choice=
if /i "%choice%"=="Y" (
explorer dist
)
pause