我常用的setup.py是这样的:
#!/usr/bin/env python
#-*- coding: gb2312 -*-
from distutils.core import setup
import py2exe
options = {"py2exe":
{ "compressed": 1,
"optimize": 2,
"bundle_files": 1,
"includes": ["encodings", "encodings.*"],
"dll_excludes": [ "MSVCP90.dll", "mswsock.dll", "powrprof.dll"],
#出现ImportError: MemoryLoadLibrary failed loading win32api.pyd
#的解决方法就是dll这一行
}
}
setup(
version = "0.1.0",
description = "a simple Python program by Tooktang",
name = "program name",
options = options,
zipfile=None,
console = [ #如果不想要命令行窗口出现可以把console换成windows
#但如果py中含有raw_input则必须使用console
#否则会有EOFError: EOF when reading a line错误出现
{
"script": "1.py",
"icon_resources": [(1, "1.ico")] #经过试验,ico图标最大只支持到32*32的像素
}
],
data_files=[("dir",["file","file2"]),("dir2",["file3","file4"])
] #如有其它需要添加的文件如数据库,按此格式,分为元组,元组第一项为文件要放置的目录(此目录放置在dist目录下,如果不要新建目录则写""就可以了)
#元组第二项为要文件,列表格式
)