Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py2app- What's the difference between the "includes" and "packages" variables?

Tags:

py2app

I'm trying to package a Linux program for Mac OS X using py2app. My setup.py looks like this:

"includes": "sip,numpy,cherrypy,cPickle,md5,logging,shutil,xml.sax,PyQt4,PyQt4.QtCore",
"resources": "mnemosyne",
"iconfile": "pixmaps/mnemosyne.icns",
"packages": "mnemosyne,mnemosyne.pyqt_ui,mnemosyne.libmnemosyne,mnemosyne.libmnemosyne.translators,mnemosyne.libmnemosyne.card_types,mnemosyne.libmnemosyne.databases,mnemosyne.libmnemosyne.file_formats,mnemosyne.libmnemosyne.filters,mnemosyne.libmnemosyne.loggers,mnemosyne.libmnemosyne.plugins,mnemosyne.libmnemosyne.renderers,mnemosyne.libmnemosyne.render_chains,mnemosyne.libmnemosyne.schedulers,mnemosyne.libmnemosyne.controllers,mnemosyne.libmnemosyne.ui_components,mnemosyne.libmnemosyne.statistics_pages,mnemosyne.libmnemosyne.review_controllers,mnemosyne.libmnemosyne.criteria,mnemosyne.libmnemosyne.upgrades,mnemosyne.script,mnemosyne.webserver,openSM2sync,openSM2sync.binary_formats,openSM2sync.text_formats"

But I realized I can also include the modules like this:

"includes": "sip,numpy,cherrypy,cPickle,md5,logging,shutil,xml.sax,PyQt4,PyQt4.QtCore,mnemosyne.pyqt_ui.*,mnemosyne.libmnemosyne.*,mnemosyne.libmnemosyne.translators.*,mnemosyne.libmnemosyne.card_types.*,mnemosyne.libmnemosyne.databases.*,mnemosyne.libmnemosyne.file_formats.*,mnemosyne.libmnemosyne.filters.*,mnemosyne.libmnemosyne.loggers.*,mnemosyne.libmnemosyne.plugins.*,mnemosyne.libmnemosyne.renderers.*,mnemosyne.libmnemosyne.render_chains.*,mnemosyne.libmnemosyne.schedulers.*,mnemosyne.libmnemosyne.controllers.*,mnemosyne.libmnemosyne.ui_components.*,mnemosyne.libmnemosyne.statistics_pages.*,mnemosyne.libmnemosyne.review_controllers.*,mnemosyne.libmnemosyne.criteria.*,mnemosyne.libmnemosyne.upgrades.*,mnemosyne.script.*,mnemosyne.webserver.*,openSM2sync.*,openSM2sync.binary_formats.*,openSM2sync.text_format.*",
"resources": "mnemosyne",
"iconfile": "pixmaps/mnemosyne.icns",

I'm not a coder so I don't really understand what is going on here. When should I use "includes" and when should I use "packages"?

like image 238
Patrick Kenny Avatar asked Jun 17 '12 02:06

Patrick Kenny


2 Answers

You don't need to explicitly name everything that you've imported in the include field. py2app has a dependency walker which will be able to tell what you've used and bundle it in for you automatically. It doesn't always work for every module so the include and exclude are there to fine-tune the process. exclude is used if py2app bundles in some extra bits you don't use; you can unzip Contents/Resources/lib/pythonX.X/site-packages.zip to see what's included in the app.

Also I believe include is for including extra python modules that didn't get automatically included where as packages will include everything in that location, not just python bits- so any and all files and file types in those locations. (I can't find a link or anything to confirm this, but from my experience this is what I understand).

like image 129
GP89 Avatar answered Nov 01 '22 02:11

GP89


They should be used for modules and packages respectively, it says so in the py2app options reference:

https://pythonhosted.org/py2app/options.html

Where packages are "dotted module names" according to http://www.network-theory.co.uk/docs/pytut/Packages.html (reference found in this topic: What's the difference between a Python module and a Python package?).

like image 24
Michiel Kauw-A-Tjoe Avatar answered Nov 01 '22 02:11

Michiel Kauw-A-Tjoe