37,741
社区成员
发帖
与我相关
我的任务
分享# coding: utf-8
from distutils.core import setup
import py2exe
import sys
#deal with some case after packing, such as run with error "LookupError: unknown encoding: utf-8"
includes = ["encodings", "encodings.*", "dbhash", "email.mime.*", "email.*"]
excludes = []
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# for the versioninfo resources
self.version = "1.0"
self.company_name = "GxLucent"
self.copyright = "gyzhang"
self.name = "ddc update"
#Put content in *.exe.manifest here, the key to resolve XP sytle after pack
manifest_template = '''
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="*.*.*" type="win32" />
<description>*</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
</assembly>
'''
RT_MANIFEST = 24
#detail setting about the target program.
Main = Target(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = "0.1",
description = "ddc update",
name = "CMmTarget",
# what to build, script equals your program's file name
script = "MainFrame.py",
other_resources = [(RT_MANIFEST, 1, manifest_template)],
#icon.ico is the target program's icon
icon_resources = [(1, r"pic/Downloads.ico")],
#target exe file name is FileSynchronizer here
dest_base = "ddcupdator"
)
# pack the FileSynchronizer
setup(
options = {
"py2exe": { # typelib for WMI
"typelibs": [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)],
# create a compressed zip archive
"compressed": 1,
"optimize": 2,
"ascii": 1,
"bundle_files": 1,
"includes": includes,
"excludes": excludes
}
},
# The lib directory contains everything except the executables and the python dll.
# Can include a subdirectory name.
zipfile = None,
#remove the DOS window when run the program, replace "console" with "windows"
windows = [Main],
#all file list below will be include in the pack folder.
#data_files=[("", ["icon", ]),]
)