我将 cx_Freeze 与以下设置脚本一起使用:
exe = Executable(
script="pyWindowAllignmentGUI.py",
base="Win32GUI"
)
setup(
name = "pyWindowAllignmentGUI",
version = "0.1",
description = "An example wxPython script",
executables = [exe]
)
这很好用。现在我尝试使用此安装脚本将所有库压缩到一个 zip 文件
build_exe_options={"compressed"}
exe = Executable(
script="pyWindowAllignmentGUI.py",
base="Win32GUI"
)
setup(
name = "pyWindowAllignmentGUI",
version = "0.1",
options = {"build_exe":build_exe_options},
description = "An example wxPython script",
executables = [exe]
)
但我收到以下错误:
Traceback (most recent call last):
File "setup.py", line 26, in <module>
executables = [exe]
File "d:\Program Files (x86)\Python3.2.3_64bit\lib\site-packages\cx_Freeze\dist.py", line 365, in setup
distutils.core.setup(**attrs)
File "d:\Program Files (x86)\Python3.2.3_64bit\lib\distutils\core.py", line 109, in setup
_setup_distribution = dist = klass(attrs)
File "d:\Program Files (x86)\Python3.2.3_64bit\lib\site-packages\cx_Freeze\dist.py", line 23, in __init__
distutils.dist.Distribution.__init__(self, attrs)
File "d:\Program Files (x86)\Python3.2.3_64bit\lib\distutils\dist.py", line 233, in __init__
for (opt, val) in cmd_options.items():
AttributeError: 'set' object has no attribute 'items'
我尝试根据此站点使用“压缩”参数: http: //cx-freeze.readthedocs.org/en/latest/distutils.html#distutils 但我似乎做错了什么?那么如何正确使用压缩参数呢?
更新:
我发现这就是这样做的方法:
build_exe_options={"compressed":True}
exe = Executable(
script="pyWindowAllignmentGUI.py",
base="Win32GUI"
)
setup(
name = "pyWindowAllignmentGUI",
version = "0.1",
options = {"build_exe":build_exe_options},
description = "An example wxPython script",
executables = [exe]
)
我进一步发现,压缩参数默认为 True 。
因此,我的构建目录中有一个 library.zip,其中存储了所有 python 文件。但我的构建文件夹中仍然有几个 .dll 和一些 .pyd 文件。(python32.dll,pythoncom32.dll,pywintypes32.dll,tcl85.dll,tk85.dll,unicodedata.pyd,win32api.pyd,win32gui.pyd,...)
是否可以以它们也在 zip 文件中的方式配置设置脚本?