-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex_setup.py
242 lines (126 loc) · 5.86 KB
/
complex_setup.py
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import sys
import traceback
from cx_Freeze import setup, Executable
# import msilib
# Dependencies are automatically detected, but it might need fine tuning.
def get_windows_text(txt):
# return txt.encode('gbk')
return txt
#中文需要显式用gbk方式编码
version = '0.2.1'
program_name = u'Gutin谷田会议视频录播管理系统'
program_windows_name = get_windows_text(program_name)
unprogram_windows_name = get_windows_text(u'卸载'+program_name)
program_des = get_windows_text(program_name+u"客户端程序 Ver."+version)
program_icon = "resource/gutin.ico"
work_dir = 'record-gutin'
#uuid叫通用唯一识别码,后面再卸载快捷方式中要用到
program_code = 'recordwindow'+version
#主程序手动命名
target_name= 'RecordWindow.exe'
build_exe_options = {
'include_files':['resource','ffmpeg-shared'], #包含外围的ini、jpg文件,以及data目录下所有文件,以上所有的文件路径都是相对于cxsetup.py的路径。
# "packages": ["os"], #包含用到的包
# "includes": ["PIL","traceback"],
# "excludes": ["tkinter"], #提出wx里tkinter包
# "path": sys.path, #指定上述的寻找路径
# "icon": program_icon #指定ico文件
};
#快捷方式表,这里定义了三个快捷方式
shortcut_table = [
#1、桌面快捷方式
(program_windows_name, # Shortcut
"DesktopFolder", # Directory_ ,必须在Directory表中
program_windows_name, # Name
"TARGETDIR", # Component_,必须在Component表中
"[TARGETDIR]"+target_name, # Target
None, # Arguments
program_des, # Description
None, # Hotkey
program_icon, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
),
#2、开始菜单快捷方式
(program_windows_name, # Shortcut
"MenuDir", # Directory_
program_windows_name, # Name
"TARGETDIR", # Component_
"[TARGETDIR]"+target_name, # Target
None, # Arguments
program_des, # Description
None, # Hotkey
program_icon, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
),
#3、程序卸载快捷方式
(unprogram_windows_name, # Shortcut
"MenuDir", # Directory_
unprogram_windows_name, # Name
"TARGETDIR", # Component_
"[System64Folder]msiexec.exe", # Target
r"/x"+program_code, # Arguments
program_des, # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
)
]
#手动建设的目录,在这里定义。
'''
自定义目录说明:
==============
1、3个字段分别为 Directory,Directory_Parent,DefaultDir
2、字段1指目录名,可以随意命名,并在后面直接使用
3、字段2是指字段1的上级目录,上级目录本身也是需要预先定义,除了某些系统自动定义的目录,譬如桌面快捷方式中使用DesktopFolder
参考网址 https://msdn.microsoft.com/en-us/library/aa372452(v=vs.85).aspx
'''
directories = [
( "ProgramMenuFolder","TARGETDIR","." ),
( "MenuDir", "ProgramMenuFolder", work_dir)
]
# Now create the table dictionary
# 也可把directories放到data里。
'''
快捷方式说明:
============
1、windows的msi安装包文件,本身都带一个install database,包含很多表(用一个Orca软件可以看到)。
2、下面的 Directory、Shortcut都是msi数据库中的表,所以冒号前面的名字是固定的(貌似大小写是区分的)。
3、data节点其实是扩展很多自定义的东西,譬如前面的directories的配置,其实cxfreeze中代码的内容之一,就是把相关配置数据写入到msi数据库的对应表中
参考网址:https://msdn.microsoft.com/en-us/library/aa367441(v=vs.85).aspx
'''
msi_data = {#"Directory":directories ,
"Shortcut": shortcut_table
}
# Change some default MSI options and specify the use of the above defined tables
#注意product_code是我扩展的,现有的官网cx_freeze不支持该参数,为此简单修改了cx_freeze包的代码,后面贴上修改的代码。
bdist_msi_options = {
# 'data': msi_data,
'add_to_path': False,
'directories': directories,
'initial_target_dir': r'[ProgramFilesFolder]\%s' % (work_dir)}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None;
if sys.platform == "win32":
base = "Win32GUI"
#简易方式定义快捷方式,放到Executeable()里。
#shortcutName = "AppName",
#shortcutDir = "ProgramMenuFolder"
setup(
name = program_windows_name.encode('gbk'),
author='林潇',
version = version,
description = program_des,
options = {"build_exe": build_exe_options,"bdist_msi": bdist_msi_options},
executables = [Executable(
"RecordWindow.py",
targetName= target_name,
base=base,
icon = program_icon)
])