我在Windows系统上使用Python2.6和cx_Freeze 4.1.2。我创建了setup.py来构建我的可执行文件,一切都很好。
当cx_Freeze运行时,它会将所有内容移动到build目录中。我有一些其他文件,我希望这些文件包含在我的build目录中。我该怎么做?这是我的结构:
src\
setup.py
janitor.py
README.txt
CHNAGELOG.txt
helpers\
uncompress\
unRAR.exe
unzip.exe这是我的片段:
设置 ( name='Janitor',version='1.0',description='Janitor',author=‘john.doe’,author_email='john.doe@gmail.com',url='http://www.this-page-intentionally-left-blank.org/',data_files =[ ('helpers\uncompress','helpers\uncompress\unzip.exe'),('helpers\uncompress','helpers\uncompress\unRAR.exe'),('','README.txt'),可执行文件= Executable\ ( 'janitor.py',#initScript )
我似乎不能让这件事起作用。我需要一个MANIFEST.in文件吗?
发布于 2010-05-23 17:31:24
弄明白了。
from cx_Freeze import setup,Executable
includefiles = ['README.txt', 'CHANGELOG.txt', 'helpers\uncompress\unRAR.exe', , 'helpers\uncompress\unzip.exe']
includes = []
excludes = ['Tkinter']
packages = ['do','khh']
setup(
name = 'myapp',
version = '0.1',
description = 'A general enhancement utility',
author = 'lenin',
author_email = 'le...@null.com',
options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [Executable('janitor.py')]
)注意:
include_files必须包含到setup.py脚本的“只”相对路径,否则构建将失败。include_files可以是一个字符串列表,即一堆文件及其相对路径
或include_files可以是一个元组列表,其中元组的前半部分是带有绝对路径的文件名,下半部分是带有绝对路径的目标文件名。(当缺乏文档时,请咨询青蛙Kermit )
发布于 2011-10-19 09:18:00
有一个更复杂的例子是:冻结- wxPyWiki
缺少所有选项的文档位于:冻结(互联网档案)
使用cx_Freeze,我仍然可以在一个文件夹中获得11个文件的生成输出,这与Py2Exe不同。
替代品:包装鼠标大战。Python
发布于 2014-06-08 08:56:53
此外,您还可以创建单独的脚本,在生成后复制文件。这就是我用来在windows上重建应用程序的地方(您应该安装“win32的GNU实用程序”以使"cp“工作)。
build.bat:
cd .
del build\*.* /Q
python setup.py build
cp -r icons build/exe.win32-2.7/
cp -r interfaces build/exe.win32-2.7/
cp -r licenses build/exe.win32-2.7/
cp -r locale build/exe.win32-2.7/
pausehttps://stackoverflow.com/questions/2553886
复制相似问题