yj
2025-09-03 f28ac0166536a2a4b68cac685a41ea667f60f7e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- mode: python ; coding: utf-8 -*-
import os
import sys
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
 
# 获取项目根目录
project_root = os.path.abspath('.')
 
# 收集所有数据文件
datas = []
 
# 添加配置文件
datas.append(('config.example.json', '.'))
if os.path.exists('config.json'):
    datas.append(('config.json', '.'))
 
# 添加日志目录
if os.path.exists('logs'):
    datas.append(('logs', 'logs'))
 
# 收集FastAPI和其他包的数据文件
datas.extend(collect_data_files('fastapi'))
datas.extend(collect_data_files('uvicorn'))
datas.extend(collect_data_files('pydantic'))
datas.extend(collect_data_files('sqlalchemy'))
 
# 收集隐藏导入
hiddenimports = []
hiddenimports.extend(collect_submodules('uvicorn'))
hiddenimports.extend(collect_submodules('fastapi'))
hiddenimports.extend(collect_submodules('pydantic'))
hiddenimports.extend(collect_submodules('sqlalchemy'))
hiddenimports.extend(collect_submodules('pymysql'))
hiddenimports.extend(collect_submodules('redis'))
hiddenimports.extend(collect_submodules('celery'))
hiddenimports.extend(collect_submodules('loguru'))
hiddenimports.extend(collect_submodules('cryptography'))
hiddenimports.extend(collect_submodules('requests'))
hiddenimports.extend(collect_submodules('httpx'))
 
# 添加特定的隐藏导入
hiddenimports.extend([
    'uvicorn.lifespan.on',
    'uvicorn.lifespan.off',
    'uvicorn.protocols.websockets.auto',
    'uvicorn.protocols.websockets.websockets_impl',
    'uvicorn.protocols.http.auto',
    'uvicorn.protocols.http.h11_impl',
    'uvicorn.protocols.http.httptools_impl',
    'uvicorn.loops.auto',
    'uvicorn.loops.asyncio',
    'uvicorn.logging',
    'pymysql.converters',
    'pymysql.cursors',
    'pymysql.connections',
    'sqlalchemy.dialects.mysql.pymysql',
    'sqlalchemy.pool',
    'sqlalchemy.engine.default',
    'app.api.callback',
    'app.models.database',
    'app.workers.message_worker',
    'app.services.message_processor',
    'app.services.dify_client',
    'app.services.ecloud_client',
    'app.services.redis_queue',
    'app.utils.logger',
])
 
# 排除不需要的模块
excludes = [
    'tkinter',
    'matplotlib',
    'numpy',
    'pandas',
    'scipy',
    'PIL',
    'IPython',
    'jupyter',
    'notebook',
    'pytest',
    'test',
    'tests',
]
 
block_cipher = None
 
a = Analysis(
    ['startup.py'],
    pathex=[project_root],
    binaries=[],
    datas=datas,
    hiddenimports=hiddenimports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=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='ecloud_dify',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=None,
)