fix: 修复Windows打包Python 3.13兼容性问题
- 升级SQLAlchemy到2.0.36+以支持Python 3.13 - 升级PyQt6到6.7.0+解决DLL加载问题 - 添加setuptools作为构建依赖 - 添加build/dist清理步骤 - 改进输出格式和错误信息
This commit is contained in:
67
build.bat
67
build.bat
@@ -6,7 +6,7 @@ REM ================================
|
|||||||
REM Change to project directory
|
REM Change to project directory
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
|
||||||
REM Check Python and install PyInstaller if needed
|
REM Check Python
|
||||||
echo Checking Python...
|
echo Checking Python...
|
||||||
python --version 2>nul
|
python --version 2>nul
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
@@ -15,51 +15,60 @@ if errorlevel 1 (
|
|||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
REM Get Python version
|
||||||
|
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set PYVER=%%i
|
||||||
|
echo Detected Python %PYVER%
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
python -m pip list 2>nul 2>&1 | findstr /I "PyInstaller" /I "install"
|
echo 1/5. Installing PyInstaller...
|
||||||
if errorlevel 1 (
|
python -m pip install --user pyinstaller 2>nul
|
||||||
echo PyInstaller not found, installing now...
|
|
||||||
python -m pip install --user pyinstaller
|
|
||||||
echo.
|
|
||||||
echo NOTE: This may take a minute...
|
|
||||||
)
|
|
||||||
python -m pip list 2>nul 2>&1 | findstr /I "PyInstaller" /I "installed"
|
|
||||||
echo.
|
|
||||||
echo If PyInstaller is installed, will proceed with build.
|
|
||||||
)
|
|
||||||
|
|
||||||
REM Check PyQt6 availability
|
echo.
|
||||||
python -c "import PyQt6.QtCore" 2>nul 2>&1
|
echo 2/5. Installing dependencies (compatible with Python 3.13)...
|
||||||
if errorlevel 1 (
|
REM Use SQLAlchemy 2.0.36+ for Python 3.13 compatibility
|
||||||
echo.
|
python -m pip install --user "sqlalchemy>=2.0.36" 2>nul
|
||||||
echo PyQt6 Core not available, will install now...
|
python -m pip install --user "PyQt6>=6.7.0" 2>nul
|
||||||
python -m pip install --user pyqt6-core
|
|
||||||
echo.
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
REM Install all required dependencies
|
|
||||||
echo Installing all dependencies...
|
|
||||||
python -m pip install --user pyqt6-gui 2>nul
|
|
||||||
python -m pip install --user sqlalchemy 2>nul
|
|
||||||
python -m pip install --user pyyaml 2>nul
|
python -m pip install --user pyyaml 2>nul
|
||||||
python -m pip install --user requests 2>nul
|
python -m pip install --user requests 2>nul
|
||||||
python -m pip install --user pillow 2>nul
|
python -m pip install --user pillow 2>nul
|
||||||
python -m pip install --user pyperclip 2>nul
|
python -m pip install --user pyperclip 2>nul
|
||||||
|
|
||||||
|
REM Install build dependencies
|
||||||
|
python -m pip install --user setuptools 2>nul
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo 3/5. Building lightweight version...
|
echo 3/5. Cleaning previous build...
|
||||||
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 exist build rmdir /s /q build
|
||||||
|
if exist dist rmdir /s /q dist
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 4/5. Building executable...
|
||||||
|
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 (
|
if errorlevel 1 (
|
||||||
|
echo.
|
||||||
|
echo ================================
|
||||||
echo Build Failed!
|
echo Build Failed!
|
||||||
|
echo ================================
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
echo ================================
|
echo ================================
|
||||||
echo Build Complete!
|
echo Build Complete!
|
||||||
echo Executable: dist\CutThenThink.exe
|
echo Executable: dist\CutThenThink.exe
|
||||||
echo File size (without PaddleOCR): ~30-50 MB
|
echo File size: ~30-50 MB
|
||||||
echo ================================
|
echo ================================
|
||||||
echo.
|
echo.
|
||||||
echo On first run, app will auto-download and install PaddleOCR.
|
echo On first run, app will auto-download and install PaddleOCR.
|
||||||
|
|||||||
Reference in New Issue
Block a user