| @echo off |
| setlocal enabledelayedexpansion |
| |
| |
| cd /d %~dp0.. |
| echo 当前工作目录:%cd% |
| |
| |
| echo 清理旧的构建... |
| if exist backend\dist rmdir /s /q backend\dist |
| if exist backend\build rmdir /s /q backend\build |
| if exist VideoMemo_frontend\src-tauri\bin rmdir /s /q VideoMemo_frontend\src-tauri\bin |
| echo 清理完成。 |
| |
| |
| mkdir VideoMemo_frontend\src-tauri\bin |
| |
| |
| for /f "tokens=2 delims=:" %%A in ('rustc -Vv ^| findstr "host"') do ( |
| set "TARGET_TRIPLE=%%A" |
| ) |
| set "TARGET_TRIPLE=%TARGET_TRIPLE: =%" |
| echo Detected target triple: %TARGET_TRIPLE% |
| |
| |
| |
| |
| |
| echo 为打包准备 .env 文件... |
| copy backend\.env.example backend\.env |
| |
| |
| echo 开始 PyInstaller 打包... |
| pyinstaller ^ |
| -y ^ |
| --name VideoMemoBackend ^ |
| --paths backend ^ |
| --distpath VideoMemo_frontend\src-tauri\bin ^ |
| --workpath backend\build ^ |
| --specpath backend ^ |
| --hidden-import uvicorn ^ |
| --hidden-import fastapi ^ |
| --hidden-import starlette ^ |
| --hidden-import chromadb.api.rust ^ |
| --collect-all chromadb ^ |
| --collect-all chromadb_rust_bindings ^ |
| --exclude-module torch ^ |
| --exclude-module torchvision ^ |
| --exclude-module torchaudio ^ |
| --exclude-module mlx_whisper.torch_whisper ^ |
| --add-data "app\db\builtin_providers.json;." ^ |
| --add-data ".env;." ^ |
| backend\main.py |
| |
| |
| echo 清理临时的 .env 文件... |
| del backend\.env |
| |
| |
| |
| |
| |
| move /Y VideoMemo_frontend\src-tauri\bin\VideoMemoBackend\VideoMemoBackend.exe VideoMemo_frontend\src-tauri\bin\VideoMemoBackend\VideoMemoBackend-%TARGET_TRIPLE%.exe |
|
|
| echo PyInstaller 打包完成: |
| dir VideoMemo_frontend\src-tauri\bin\VideoMemoBackend |
|
|
| echo 请检查 VideoMemo_frontend\src-tauri\bin\VideoMemoBackend 目录,确认其中包含了名为 .env 的【文件】。 |
|
|
| endlocal |