py2exe “include” modules: when should they be managed manually?

北战南征 提交于 2019-12-17 19:45:34

问题


When is it necessary to specify modules to include? Doesn't py2exe search and include whatever is needed per: http://www.py2exe.org/index.cgi/FAQ?

And why does it include modules that are not being used, such as ["Tkconstants", "Tkinter", "tcl", "wx"] (I'm using Qt, but have wx installed on my PC) that then need to be excluded?


回答1:


py2exe tries to create a graph of all the dependencies, starting with your entry point script. It can't always get it 100% correct, which is why you are provided the includes and excludes options to fine tune the package.

Refer to options here: http://www.py2exe.org/index.cgi/ListOfOptions

Sometimes modules you didn't want will get included and if this happens just add them to the exclude. I suppose the answer to your question would be: manage the setup.py manually when the out-of-the box options don't package it exactly how you want.

The help files for py2exe actually include a bunch of tips and tricks... one specifically addressing your issue with Tk being included: http://www.py2exe.org/index.cgi/TkInter

The index of the tips and tricks is here: http://www.py2exe.org/index.cgi/Py2Exe

I've built a ton of apps using the very similar py2app for osx. Over the course of different versions, sometimes they change the way it discovers dependencies. It also uses various "recipes" for how to handle certain packages like Qt. A newer version of p2app suddenly started including all of the PyQt modules instead of just the two I used. So, I had to add them to my excludes.



来源:https://stackoverflow.com/questions/10098444/py2exe-include-modules-when-should-they-be-managed-manually

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