[Pythonmac-SIG] py2app and nested packages

Chris Barker chris.barker at noaa.gov
Mon Apr 23 23:13:40 CEST 2012


Another couple py2app questions:

I"ve discovered that my app is HUGE! -- I already expected that, but
this is a bit out of bounds. The reason:

The scipy and matplotlib packages bring in all of scipy, numpy, and
matplotlib uncompressed. This gets pretty darn big, particularly when
you're using one or two simple functions from scipy, for instance.

I know why they do that -- there are a number of dynamic inports, and
folks often include matplotlib and/or scipy in apps where people may
be scripting, etc, and using features that aren't always imported by
the app. And this way, apps using those libs "just work" which is
great.

However, it would be nice to be able to override soem of this:

Is there a way to "turn off" a recipe (other than deleting it from the install)?

- Is there a way to apply excludes after the recipe? As far as I can
tell, if the recipe includes it, excludes doesn't remove it.


-Chris



On Mon, Apr 23, 2012 at 11:42 AM, Chris Barker <chris.barker at noaa.gov> wrote:
> Folks,
>
> py2app doesn't seem to do "the right thing" with nested packages.
> However, it's not entirely clear what it should do...
>
> example: the "pubsub" package is delivered with wxPython, so it is
> commonly imported thusly:
>
> from wx.lib.pubsub import Publisher
>
> However, in wx.lib.pubsub, there is some trickery in the __init___, so
> as py2app installs it, ot doesn't work (see previous messages to this
> and the wxPython list). However, if you do:
>
> packages = ['wx.lib.pubsub']  ...
>
> in your py2app setup.py, you get the entire pubsub package, but installed in :
>
> Peppy.app/Contents/Resources/lib/python2.7/pubsub
>
> so it will work, but only if you now import it as:
>
> from pubsub import Publisher
>
> not too heinous, but it's really nice if we don't have to change
> imports for the bundled version.
>
> if I add 'wx' to packages, It does work, but I've then got all of wx,
> all of wx.lib, etc, which is  really a bit much (the resulting app
> bundle is 124MB, vs. 60 without specifying the wx package)
>
> At first, I thought I'd want:
>
> wx/lib/pubsub/....
>
> put on sys.path, with wx and lib empty except the specified dirs.
> However, that would put two "wx" dirs on sys.path, which would not be
> good (assuming wx is used...)
>
> Would it be possible for the packages specification to be processed
> after modulegraph is run, and it would then see that "wx" and "wx.lib"
> are there, and then put all of pubsub in there? Or maybe put the parts
> of wx and wx.lib that were already going to be included outside the
> zip bundle?
>
> -Chris
>
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker at noaa.gov



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list