An easier (and better) way to create
single-file executables is to set
bundle_files to 1 or 2, and to set
zipfile to None. This approach does
not require extracting files to a
temporary location, which provides
much faster program startup.
Valid values for bundle_files are:
3 (default) don't bundle
2 bundle everything but the Python interpreter
1 bundle everything, including the Python interpreter
If zipfile is set to None, the files will be bundle
within the executable instead of library.zip.
下面是setup.py示例:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = [{'script': "single.py"}],
zipfile = None,
)
使用py2exe执行此操作的方法是在setup.py文件中使用bundle_files选项。对于单个文件,您需要将
bundle_files
设置为1,compressed
设置为True,并将zipfile选项设置为None。这样它就创建了一个压缩文件,便于分发下面是直接从py2exe site*引用的bundle_file选项的更完整描述
下面是setup.py示例:
正如另一张海报所提到的,
py2exe
将生成一个可执行文件+一些要加载的库。您还可以将一些数据添加到程序中下一步是使用安装程序,将所有这些打包成一个易于使用的可安装/不可安装程序
几年来,我一直很高兴地使用InnoSetup,并将其用于商业项目,因此我衷心推荐它
PyInstaller将创建一个没有依赖项的.exe文件;使用
--onefile
选项。它通过将所有需要的共享lib打包到可执行文件中,并在运行之前解压缩它们来实现这一点,正如您所描述的(EDIT:py2exe也有此功能,请参见minty's answer)我使用svn的PyInstaller版本,因为最新版本(1.3)有些过时。对于一个依赖于PyQt、PyQwt、numpy、scipy等的应用程序来说,它一直运行得非常好
相关问题 更多 >
编程相关推荐