Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py2exe "include" modules: when should they be managed manually?

Tags:

python

py2exe

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?

like image 483
tosa Avatar asked Apr 11 '12 00:04

tosa


1 Answers

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.

like image 192
jdi Avatar answered Oct 10 '22 11:10

jdi