Files
datie-bom/build.spec
2026-04-27 15:24:41 +08:00

75 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- mode: python ; coding: utf-8 -*-
import os
block_cipher = None
# 获取当前工作目录(项目根目录)
PROJECT_ROOT = os.path.abspath('.')
# 动态组装需要打包的静态数据文件
datas = [
('web_ui/templates', 'web_ui/templates')
]
if os.path.exists(os.path.join(PROJECT_ROOT, 'web_ui', 'static')):
datas.append(('web_ui/static', 'web_ui/static'))
if os.path.exists(os.path.join(PROJECT_ROOT, 'browser_login', '.env')):
datas.append(('browser_login/.env', 'browser_login'))
a = Analysis(
['web_ui/app.py'], # 主入口点
pathex=[
PROJECT_ROOT,
os.path.join(PROJECT_ROOT, 'browser_login') # 确保能找到抓取脚本的路径
],
binaries=[],
datas=datas,
hiddenimports=[
'flask',
'apscheduler.schedulers.background',
'apscheduler.triggers.interval', # 必须显式声明,否则打包后定时任务可能找不到触发器
'DrissionPage',
'dotenv',
'sqlite3',
# 我们通过字符串动态导入的模块,必须声明让 PyInstaller 去追踪
'fetch_receipt_details_incremental',
'fetch_bom_cost_full_tree',
'config',
'login',
'auto_launcher',
'bom_query'
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='DatieERP', # 生成的 .exe 文件名称
debug=False, # 生产环境关闭 Debug 模式
bootloader_ignore_signals=False,
strip=False,
upx=True, # 启用 UPX 压缩以减小包体积(如果环境中有的话)
upx_exclude=[],
runtime_tmpdir=None, # 使用默认临时目录 (即 sys._MEIPASS)
console=True, # 是否保留黑色命令行窗口(开发初期建议保留看日志,稳定后可改为 False
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)