python cx_Freeze鸡蛋问题 [英] python cx_Freeze egg problem

查看:126
本文介绍了python cx_Freeze鸡蛋问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im试图从python脚本(使用大量鸡蛋)构建可执行文件(用于32位Windows XP)

im trying to build an executable (for 32bit windows xp) from a python script (which uses lots of eggs)

我认为py2exe(0.6.9), PyInstaller(1.4)和cx_Freeze(4.1.2)

i considered py2exe(0.6.9), PyInstaller (1.4) and cx_Freeze (4.1.2)

py2exe不喜欢早餐吃鸡蛋

PyInstaller不喜欢在午餐时使用python 2.6

所以我选择了cx_Freeze(应该从4.0开始就无缝支持鸡蛋)。

so i went with cx_Freeze (supposed to support eggs seamlessly since 4.0). but for some reason it doesnt.

我要通过什么参数才能识别鸡蛋中的文件?

what parameters do i pass in order for files inside an egg to be recognized?

推荐答案

在源目录中解压缩eggs模块,并在setup.py中添加 package:[dependencies,]
py2Exe文档中的py2exe文档之后,我执行了您最常运行的脚本在您的源代码中执行: python unpackEgg.py eggsmodule

Unpack your eggs module in your source directory and add package: [dependencies,] in your setup.py. Following the py2exe docs in py2Exe Docs i did this script that you most run in your source executing: 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])

这篇关于python cx_Freeze鸡蛋问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆