from distutils.core import setup
import py2exe
import sys
# If run without args, build executables, in quiet mode.
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# for the versioninfo resources
self.company_name = ""
self.copyright = "Kavin 2008"
self.name = "Simple Tic Tac Toe"
################################################################
# A program using wxPython
# The manifest will be inserted as resource into iTip.exe. This
# gives the controls the Windows XP appearance (if run on XP ;-)
#
# Another option would be to store it in a file named
# iTip.exe.manifest, and copy it with the data_files option into
# the dist-dir.
#
manifest_template = """
version="5.0.0.0"
processorArchitecture="x86"
name="%(prog)s"
type="win32"
/>
%(prog)s Program
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
"""
################################################################
RT_MANIFEST = 24
Sttt = Target(
# used for the versioninfo resource
description = "A Funny Game",
# what to build
script = "SimpleTicTacToe.py",
other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="Simple Tic Tac Toe"))],
icon_resources = [(1, "edit.ico")],
dest_base = "Simple Tic Tac Toe")
setup(
options = {"py2exe": {"compressed": 1,
"optimize": 2,
"ascii": 1,
"bundle_files": 1}},
zipfile = None,
windows = [Sttt],
)
中间那段manifest_template是解决打包后XP或Vista下窗体风格样式丢失的问题,最底下的zipfile = None就是不生成library.zip等很多压缩文件,上面代码打包就能生成单个exe那样了