feat: 改为安装包分发并使用动态端口

This commit is contained in:
2026-10-25 02:31:23 +08:00
parent 5ca491834e
commit f5779369a5
34 changed files with 392 additions and 49 deletions
+48
View File
@@ -0,0 +1,48 @@
"""把后端冻成目录形式,供安装包直接启动,不在第一次打开时解压。"""
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
DIST = ROOT / "build"
def main() -> None:
DIST.mkdir(parents=True, exist_ok=True)
subprocess.check_call(
[
sys.executable,
"-m",
"PyInstaller",
"--noconfirm",
"--clean",
"--onedir",
"--name",
"nqi-backend",
"--distpath",
str(DIST),
"--workpath",
str(DIST / "pyinstaller"),
"--specpath",
str(DIST),
"--collect-submodules",
"app",
"--collect-all",
"uvicorn",
"--collect-all",
"openpyxl",
"--collect-all",
"cryptography",
"--collect-all",
"certifi",
"--hidden-import",
"multipart",
str(ROOT / "nqi_backend.py"),
],
cwd=ROOT,
)
if __name__ == "__main__":
main()