Mri*_*lla 54 python distutils cx-freeze
我在Windows系统上使用Python 2.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
Run Code Online (Sandbox Code Playgroud)
这是我的片段:
建立
Run Code Online (Sandbox Code Playgroud)( 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']) ], executables = [ Executable\ ( 'janitor.py', #initScript ) ] )
我似乎无法让这个工作.我需要一个MANIFEST.in文件吗?
Mri*_*lla 106
弄清楚了.
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')]
)
Run Code Online (Sandbox Code Playgroud)
注意:
include_files必须包含setup.py脚本的"仅"相对路径,否则构建将失败.include_files可以是一个字符串列表,即一堆文件及其相对路径include_files 可以是元组列表,其中元组的前半部分是具有绝对路径的文件名,后半部分是具有绝对路径的目标文件名.(当缺少文件时,请咨询青蛙Kermit)
有一个更复杂的例子:cx_freeze - wxPyWiki
缺少所有选项的文档在:cx_Freeze(Internet Archive)
有了cx_Freeze,我仍然可以在一个文件夹中获得11个文件的构建输出,不像Py2Exe.
替代品:包装| 鼠标VS. 蟒蛇