Repository navigation
Expand file tree
/
Copy pathbuild.spec
More file actions
138 lines (129 loc) · 3.41 KB
/
Copy pathbuild.spec
File metadata and controls
138 lines (129 loc) · 3.41 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
PyInstaller 打包配置檔案
用於將 Minecraft 伺服器管理器打包成 .exe 檔案和依賴資料夾結構
"""
# -*- mode: python ; coding: utf-8 -*-
import os
from pathlib import Path
# 取得專案根目錄
# 在 PyInstaller 環境中 __file__ 不可用,使用當前工作目錄
project_root = Path(os.getcwd())
block_cipher = None
a = Analysis(
['minecraft_server_manager.py'], # 主程式入口點
pathex=[str(project_root)], # 添加專案根目錄到搜尋路徑
binaries=[],
datas=[
# 包含必要的資料檔案和目錄
('src', 'src'), # 完整包含 src 目錄
('assets', 'assets'), # 包含 assets 資料夾(如果存在)
('README.md', '.'), # 說明文件
('LICENSE', '.'), # 授權檔案
('COPYING.md', '.'), # 版權說明
('requirements.txt', '.'), # 依賴清單
],
hiddenimports=[
# 標準函式庫 - 核心模組
'tkinter',
'tkinter.ttk',
'tkinter.messagebox',
'tkinter.filedialog',
'tkinter.scrolledtext',
'json',
'os',
'sys',
'pathlib',
'tempfile',
'shutil',
'subprocess',
'threading',
'queue',
'time',
'datetime',
'traceback',
'zipfile',
'glob',
'weakref',
'webbrowser',
'ctypes',
'urllib.parse',
'concurrent.futures',
're',
'enum',
'contextlib',
'importlib',
# 第三方套件 - 網路和資料處理
'requests',
'urllib3',
'lxml',
'lxml.etree',
'toml',
'psutil',
# 第三方套件 - GUI 框架
'customtkinter',
'darkdetect',
# 可選依賴 (如果存在)
'aiohttp',
'packaging',
'rich',
# XML 處理
'xml.etree.ElementTree',
# 資料類型和工具
'dataclasses',
'typing',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
# 排除不必要的模組以減少檔案大小
'matplotlib',
'numpy',
'pandas',
'scipy',
'PIL',
'pygame',
'cv2',
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
# 過濾掉 None 值的 datas
a.datas = [data for data in a.datas if data is not None]
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True, # 重要:將二進位檔案分離到資料夾中
name='MinecraftServerManager',
debug=False, # 設為 True 可啟用除錯模式
bootloader_ignore_signals=False,
strip=False, # Windows 上通常設為 False
upx=True, # 啟用 UPX 壓縮以減少檔案大小
upx_exclude=[],
runtime_tmpdir=None,
console=False, # 隱藏控制台視窗,提供更好的使用者體驗
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon='assets/icon.ico',
version='assets/version_info.txt'
)
# 建立分散式打包結構(exe + 依賴資料夾)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='MinecraftServerManager' # 輸出資料夾名稱
)