fix: 修复Windows打包脚本
- 简化build.bat,使用Python命令直接打包 - 移除导致错误的^续行符 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
62
build.bat
62
build.bat
@@ -1,69 +1,17 @@
|
||||
@echo off
|
||||
REM ================================
|
||||
REM CutThenThink Windows 打包脚本
|
||||
|
||||
echo ================================
|
||||
echo CutThenThink 打包脚本 (Windows)
|
||||
echo ================================
|
||||
echo.
|
||||
|
||||
REM 检查 Python
|
||||
python --version 2>nul || (
|
||||
echo 错误: 未找到 Python
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查 PyInstaller
|
||||
python -m PyInstaller --version 2>nul
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo 正在安装 PyInstaller...
|
||||
echo.
|
||||
python -m pip install --user pyinstaller
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 1/5. 安装项目依赖...
|
||||
echo.
|
||||
python -m pip install --user --upgrade pip 2>nul
|
||||
python -m pip install --user -r requirements.txt 2>nul
|
||||
|
||||
echo.
|
||||
echo 2/5. 创建轻量版打包(不包含PaddleOCR)
|
||||
echo.
|
||||
echo 说明: PaddleOCR体积很大(~200MB),首次运行时自动下载安装
|
||||
echo.
|
||||
|
||||
REM 创建临时 requirements(不含OCR)
|
||||
findstr /V "paddleocr" /V "paddlepaddle" requirements.txt > requirements_lite.txt
|
||||
|
||||
REM 打包(轻量版)
|
||||
echo 3/5. 开始打包(轻量版)...
|
||||
python -m PyInstaller ^
|
||||
--name "CutThenThink" ^
|
||||
--windowed ^
|
||||
--onefile ^
|
||||
--add-data "src:src" ^
|
||||
--hidden-import=PyQt6.QtCore ^
|
||||
--hidden-import=PyQt6.QtGui ^
|
||||
--hidden-import=PyQt6.QtWidgets ^
|
||||
--hidden-import=sqlalchemy ^
|
||||
src/main.py
|
||||
|
||||
REM ================================
|
||||
REM 使用 Python 打包,避免路径问题
|
||||
cd /d "%~dp0"
|
||||
python -m PyInstaller --noconfirm --name "CutThenThink" --windowed --onefile --add-data "src:src" --hidden-import=PyQt6.QtCore --hidden-import=PyQt6.QtGui --hidden-import=PyQt6.QtWidgets --hidden-import=sqlalchemy src/main.py
|
||||
if errorlevel 1 (
|
||||
echo 打包失败!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ================================
|
||||
echo 打包完成!
|
||||
echo 可执行文件: dist\CutThenThink.exe
|
||||
echo 文件大小(不含OCR): 约 30-50 MB
|
||||
echo ================================
|
||||
echo.
|
||||
echo 首次运行时,应用会自动下载并安装 PaddleOCR
|
||||
echo.
|
||||
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user