fix: pyinstaller

main
Dawn1Ocean 2025-10-16 14:44:38 +08:00
parent 4dc23b47ba
commit fa59daa416
Signed by untrusted user who does not match committer: Dawn_Ocean
GPG Key ID: 665725CC2E168641
10 changed files with 1470 additions and 1463 deletions

View File

@ -29,9 +29,11 @@ uv run main.py
本项目使用 `pyinstaller` 工具进行打包。如果要打包,请确保能够正常运行项目。打包命令如下:
```bash
uv run pyinstaller --onefile --windowed --name=EVA_duty_arrange_tool main.py
uv run pyinstaller --onefile --windowed --name=EVA_duty_arrange_tool --hidden-import=ortools --collect-all ortools --additional-hooks-dir=. main.py
```
> **注意**:由于 `ortools` 库包含大量 DLL 依赖,需要使用 `--collect-all ortools` 参数来收集所有必要的动态链接库。`--additional-hooks-dir=.` 参数指定使用项目根目录下的 `hook-ortools.py` 文件来确保正确打包。
## 数学原理
本项目将值班排班问题建模为了一个[组合优化](https://zh.wikipedia.org/wiki/%E7%BB%84%E5%90%88%E4%BC%98%E5%8C%96)问题,使用 Google 的 OR-Tools 求解器中的 SCIP 求解器进行求解。

5
hook-ortools.py 100644
View File

@ -0,0 +1,5 @@
from PyInstaller.utils.hooks import collect_data_files, collect_dynamic_libs
# 收集 ortools 的所有数据文件和动态链接库
datas = collect_data_files('ortools')
binaries = collect_dynamic_libs('ortools')