[Pythonmac-SIG] shrink app bundle size (removing unused stuff)?

Kevin Walzer kw at codebykevin.com
Fri Mar 9 03:38:50 CET 2012


On 3/7/12 6:09 PM, Carlos Grohmann wrote:
> Hi there,
>
> I've been reasonably successful in building an app bundle with py2app.
> I'm running OS X Lion, python 2.7.2 (from python.org), wxpython
> 2.9beta, and my app
> uses matplotlib and numpy.
>
> Using py2exe, the final folder has 14MB, or 11MB compressed.
>
> Using py2app, the .app has 250MB (!) or 100MB compressed with Disk utility
>
> Examining the Contents of the .app, I can see that there's A LOT of
> stuff I don't need,
> like Editra (11MB), Locales, or Matplotlib "tests" folder (38MB)
>
> So, how could I remove these itens from my app?
> I tried the 'excludes' option in py2app setup.py, but without any luck.
>
> Also, what are those "codecs" in lib-dynload? I have no idea what they are.
>
> my setup.py follows. (BTW, I tried to run it without any reference to
> 'wx' but then
> the app crashes)
>
> many thanks
>
> Carlos
>

I hope this isn't stating the obvious, but how about simply removing the 
unwanted bits after running setup.py? I run my py2app builds from a 
shell script because I have to do some additional manipulation of the 
app bundle. Here's an excerpt from my build script:

#!/bin/sh

echo "Starting dist process..."


if [ -a cbk/Phynchronicity.dmg ]
then
rm cbk/Phynchronicity.dmg
fi

if [ -a cbk/Phynchronicity.app ]
then
rm -rf cbk/Phynchronicity.app
fi

python2.7 setup.py py2app

mkdir dist/Phynchronicity.app/Contents/lib

#copy the supporting libraries
for lib in libs/*
do
   echo "Copying $lib library..."
   cp -R -f $lib dist/Phynchronicity.app/Contents/lib
done


cp -rf dist/Phynchronicity.app cbk/Phynchronicity.app
ditto --rsrc  --arch i386 --arch x86_64 cbk/Phynchronicity.app 
cbk/Phynchronicity_intel.app
rm -rf cbk/Phynchronicity.app
mv cbk/Phynchronicity_intel.app cbk/Phynchronicity.app


...and so on.

Hope this helps,
Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Pythonmac-SIG mailing list