python cx_Freeze egg problem

帅比萌擦擦* 提交于 2019-12-10 18:49:26

问题


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

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

py2exe doesnt like eggs for breakfast

PyInstaller doesnt like python 2.6 for lunch)

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?


回答1:


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])



回答2:


You could try PyInstaller's 2.6 branch that is linked in the page you gave.



来源:https://stackoverflow.com/questions/2633655/python-cx-freeze-egg-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!