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

2

7

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"?

Overstock answered 17/6, 2012 at 2:44 Comment(0)
A
6

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

Allare answered 18/6, 2012 at 11:6 Comment(3)
Adding our package to packages didn't include text files, apparently it doesn't includes every file type.Rem
@MichielKauw-A-Tjoe I think you want datafiles for including other file types, images/text files etc.Allare
The data_files (with underscore) argument does add files, but doesn't add non-Python files inside a package, or copy the entire path at which the files are located, which is what I need. Instead, the folder at which it points is copied into Resources next to lib, where the packages are stored. Thanks anyway!Rem
R
1

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?).

Rem answered 18/12, 2014 at 10:8 Comment(1)
Edit queue is full: but for clarity: "*Includes* should be used for modules, *packages* should be used for packages."Clypeus

© 2022 - 2024 — McMap. All rights reserved.