How to disable cx_freeze to autodetect all modules

半世苍凉 提交于 2019-12-11 04:22:10

问题


cx_freeze build includes all modules, that installed on my machine, so freezed build becomes a huge. How to disable autodetection feature? I just want to build small PyQt application:

import sys
from cx_Freeze import setup, Executable

path = sys.path + ["app"]
includes = ["app.core", "app.utils"]
excludes = ["tcl"]
build_exe_options = {
"path": path,
"icon": "resources\icons\clock.ico"}

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "app",
        version = "1.1",
        description = "My Application",
        options = {"build_exe": build_exe_options},
        executables = [Executable("app.py", base=base,
            targetName="app.exe",
            shortcutName="Application",
            shortcutDir="DesktopFolder")])

Also I have the my custom modules, each has a utils submodule, so cx_freeze put wrong module.

How can I set strict list of modules, which i need?


回答1:


It was quite simple. This application uses a custom modules, so I've added application folder to the path:

path = sys.path + ["app"]

The trick is that app uses module "utils" and I have other "utils" module in my OS path. Other "utils" module imports a lot of stuff like matplotlib, PIL, etc. So I've solved problem by changing path environment like this:

path = ["app"] + sys.path

So, cx_freeze gets right modules when freeze executable.



来源:https://stackoverflow.com/questions/16769479/how-to-disable-cx-freeze-to-autodetect-all-modules

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