-
Notifications
You must be signed in to change notification settings - Fork 46
/
realesrgan-gui-macos.spec
162 lines (149 loc) · 3.84 KB
/
realesrgan-gui-macos.spec
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# 导入模块
import os
import sys
from PyInstaller.utils.hooks import collect_data_files
import subprocess
# 获取提交哈希和构造版本号
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip()
version = "0.2.5." + commit_hash
bin = []
if os.path.exists('upscayl-bin'):
bin.append(('upscayl-bin', '.'))
elif os.path.exists('realesrgan-ncnn-vulkan'):
bin.append(('realesrgan-ncnn-vulkan', '.'))
if os.path.exists('realcugan-ncnn-vulkan'):
bin.append(('realcugan-ncnn-vulkan', '.'))
# PyInstaller分析脚本
# 指定主入口文件
a = Analysis(
['main.py'],
# 需要打包的二进制
binaries=bin,
# 需要打包的数据文件
datas=[
('models', 'models'),
('theme', 'theme'),
('i18n.ini', '.'),
('icon.icns', '.'),
('icon-128px.png', '.'),
],
# 隐藏导入
hiddenimports=[
'PIL._tkinter_finder',
],
# PyInstaller钩子目录
hookspath=[
'pyi-hooks',
],
# 排除不需要的模块
excludes=[
'_asyncio',
'_bz2',
'_decimal',
'_hashlib',
'_lzma',
'_queue',
'_ssl',
'unicodedata',
],
)
# 从binaries中排除不需要的系统dll
# Windows 10+已经自带UCRT,无需打包
a.binaries = [
x
for x in a.binaries
if not any(x[0].startswith(y) for y in {
'api-ms-win-',
'ucrtbase.dll',
})
]
# 从datas中排除不需要的tcl/tk文件,经测试这些文件实际上没有用到
a.datas = [
x
for x in a.datas
if not any(x[0].startswith(y) for y in {
os.path.join('tcl', 'encoding'),
os.path.join('tcl', 'http'),
os.path.join('tcl', 'msgs'),
os.path.join('tcl', 'opt'),
os.path.join('tcl', 'tzdata'),
os.path.join('tcl8'),
os.path.join('tk', 'images'),
os.path.join('tk', 'msgs'),
})
]
# 打印binaries和datas的调试信息
print('Binaries:')
for i in a.binaries:
print(i)
print('Datas:')
for i in a.datas:
print(i)
# 生成PYZ文件
pyz = PYZ(a.pure, a.zipped_data)
# 构建可执行文件
if os.environ.get('REGUI_ONEFILE'):
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='realesrgan-gui',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
icon='icon.icns',
)
else:
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='realesrgan-gui',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
icon='icon.icns',
)
# 收集所有文件打包
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
name='realesrgan-gui',
strip=False,
upx=True,
)
# 生成macOS应用
app = BUNDLE(
coll,
name='Real-ESRGAN GUI.app',
icon='icon.icns',
bundle_identifier=None,
info_plist={
'CFBundleDisplayName': 'Real-ESRGAN GUI',
'CFBundleName': 'Real-ESRGAN GUI',
'CFBundlePackageType': 'APPL',
'CFBundleSignature': 'RLES',
'CFBundleShortVersionString': version,
'CFBundleVersion': version,
'CFBundleExecutable': 'realesrgan-gui',
'CFBundleIconFile': 'icon.icns',
'CFBundleIdentifier': 'dev.transparentlc.regui',
'CFBundleInfoDictionaryVersion': '6.0',
'LSApplicationCategoryType': 'public.app-category.graphics-design',
'LSEnvironment': {'LANG': 'zh_CN.UTF-8'},
}
)