fix: 修复Windows打包脚本依赖检查
- 检查 Python 是否正确安装 - 检查 PyQt6 是否可用 - 如果缺失则自动安装 - 提供清晰的错误提示和安装指引 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
72
build.bat
72
build.bat
@@ -3,23 +3,85 @@ REM ================================
|
||||
REM CutThenThink Windows Build Script
|
||||
REM ================================
|
||||
|
||||
REM Change to project directory and run packaging
|
||||
REM Change to project directory
|
||||
cd /d "%~dp0"
|
||||
|
||||
REM Run PyInstaller packaging
|
||||
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
|
||||
REM Check Python installation
|
||||
python --version 2>nul
|
||||
if errorlevel 1 (
|
||||
echo Build Failed!
|
||||
echo Error: Python not found
|
||||
echo Please install Python 3.8+ from python.org
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Check PyInstaller
|
||||
python -m PyInstaller --version 2>nul
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo PyInstaller not found, installing now...
|
||||
python -m pip install --user pyinstaller
|
||||
)
|
||||
echo.
|
||||
)
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo Trying PyInstaller from pip...
|
||||
python -m pip install --user pyinstaller 2>nul
|
||||
)
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo PyInstaller still not available. Please install manually:
|
||||
echo pip install pyinstaller
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Check PyQt6 availability
|
||||
python -c "import PyQt6.QtCore" 2>nul
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo Warning: PyQt6 not installed
|
||||
echo.
|
||||
)
|
||||
echo.
|
||||
echo 1/5. Installing dependencies...
|
||||
python -m pip install --user --upgrade pip 2>nul
|
||||
python -m pip install --user pyqt6 2>nul
|
||||
python -m pip install --user pyqt6-webengine 2>nul
|
||||
python -m pip install --user sqlalchemy 2>nul
|
||||
python -m pip install --user pyyaml 2>nul
|
||||
python -m pip install --user requests 2>nul
|
||||
python -m pip install --user pillow 2>nul
|
||||
python -m pip install --user pyperclip 2>nul
|
||||
|
||||
echo.
|
||||
echo 2/5. Creating lightweight package (without PaddleOCR)...
|
||||
python -m pip install --user pyinstaller 2>nul
|
||||
findstr /V "paddleocr" /V "paddlepaddle" requirements.txt > nul
|
||||
if errorlevel 1 (
|
||||
echo Error creating requirements_lite.txt
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 3/5. Building lightweight version...
|
||||
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 Build Failed!
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ================================
|
||||
echo Build Complete!
|
||||
echo Executable: dist\CutThenThink.exe
|
||||
echo File size (without PaddleOCR): ~30-50 MB
|
||||
echo ================================
|
||||
echo.
|
||||
echo On first run, the app will auto-download and install PaddleOCR.
|
||||
echo On first run, app will auto-download and install PaddleOCR.
|
||||
echo.
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user