我试图从Python脚本(使用大量鸡蛋)构建一个可执行文件(适用于32位Windows XP)
我考虑过 py2exe(0.6.9)、PyInstaller (1.4) 和 cx_Freeze (4.1.2)
py2exe 不喜欢早餐吃鸡蛋 http://www.py2exe.org/index.cgi/ExeWithEggs
PyInstaller 不喜欢用 python 2.6 作为午餐 http://www.pyinstaller.org/wiki/Python26Win)
所以我选择了 cx_Freeze (从 4.0 开始应该无缝支持鸡蛋 http://cx-freeze.sourceforge.net/HISTORY.txt)。但由于某种原因,事实并非如此。
我需要传递哪些参数才能识别 Egg 内的文件?
在源目录中解压 Eggs 模块并添加package: [dependencies,]
在你的 setup.py 中。
遵循 py2exe 文档py2Exe 文档 http://www.py2exe.org/index.cgi/ExeWithEggs我做了这个您最常在源执行中运行的脚本:python unpackEgg.py eggsmodule
:
import os
import pkg_resources
import sys
from setuptools.archive_util import unpack_archive
def unpackEgg(modulo):
eggs = pkg_resources.require(modulo)
for egg in eggs:
if os.path.isdir(egg.location):
sys.path.insert(0, egg.location)
continue
unpack_archive(egg.location, ".")
eggpacks = set()
eggspth = open("./eggs.pth", "w")
for egg in eggs:
print egg
eggspth.write(os.path.basename(egg.location))
eggspth.write("\n")
eggpacks.update(egg.get_metadata_lines("top_level.txt"))
eggspth.close()
eggpacks.clear()
if __name__ == '__main__':
unpackEgg(sys.argv[1])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)