record-camera-and-screen/complex_setup.py

242 lines
5.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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)
])