[Pythonmac-SIG] py2app with genshi problem

David Bolen db3l.net at gmail.com
Sun Sep 4 23:17:00 CEST 2011


Neacsa Bogdan Valentin <neacsa_bogdan_valentin at yahoo.com> writes:

>  cherrypy.tools.buffet_genshi = BuffetTool('genshi', 'tvb.interfaces.web.templates.genshi')
> here, 'tvb'.interface.web.templates.genshi' is a 'python package' in the sense that there is an __init__.py there and the only thing in that folder are the html templates for our project.
> If anyone has at least a hind on what might be causing this please share.

While I haven't used that package, and have used genshi directly with
py2app without much special handling, given the way you reference the
package it seems likely that it is imported dynamically (via code),
and thus there may not be an explicit import for py2app to track.

Is the tvb.interfaces.web.templates.genshi package actually getting
included in the packaged application?  If not, that's your root issue
and you need to let py2app know that it needs to include it.

This is, by the way, a general approach to these sorts of "error only
shows up when packaged" issues.  The most likely cause is that the use
of some piece of your application - most often something dynamically
referenced - wasn't included able to be automatically detected.

Assuming that's the case here, you could try adding it explicitly via
the 'packages' options setup() parameter in your setup module to force
its inclusion, e.g.:

    setup(
       ...
       options = {'packages': 'tvb.interfaces.web.templates.genshi'}
       ...
    )

(If you already have options, just augment with that)

Since your package is templates, I'm not absolutely sure if all the
relevant files will get pulled in this way (I can't remember if it
pulls in the entire package directory contents or not), but it's the
simplest to try first.  If it skips non-python template files, then
you may need to work out a different method (such as perhaps the
data_files parameter to setup()) to force the inclusion of your
templates.  If you have a mixture of dynamic package references and
in-package data files in those packages, getting it all to end up in
the right spot in the packaged version can sometimes be a challenge.
You may find separating out the pure data files into their own tree to
be easier.

-- David



More information about the Pythonmac-SIG mailing list