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

Ronald Oussoren ronaldoussoren at mac.com
Fri Mar 9 05:43:32 CET 2012


On 7 Mar, 2012, at 15:09, 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)

matplatlib is included as is because it won't work when you include only the bits that are referenced in the "import" graph, I'll check how hard it will be to exclude the tests in this copy.

The only editra I could find was <http://editra.org/> which is an editor, I don't know why that gets copied into your application. How did you install Editra, did you use the binary DMG on the website, or did you install from source?

I don't know what "Locales" is at all. Is there a python package on  your system that is named "Locales"? 

> 
> So, how could I remove these itens from my app?
> I tried the 'excludes' option in py2app setup.py, but without any luck.

That this didn't work for matplotlib is expected, a py2app recipe for matplotlib overrides your exclude option. 
> 
> Also, what are those "codecs" in lib-dynload? I have no idea what they are.

The codecs are the stdlib support for translating between bytestrings and unicode in various encodings.  These are implicitly imported when you use the codecs module (either directory or through somestring.decoe("encoding").  Py2app cannot detect if you do this and therefore conservatively includes all encodings just in case they are needed.  Adding a way to specify which encodings should be included would be nice, I'm not sure when I'll get around to implementing this.

> 
> my setup.py follows. (BTW, I tried to run it without any reference to
> 'wx' but then
> the app crashes)

Can you reproduce this using a smaller example?  

BTW. Are you trying to package this OpenStereo: http://www.igc.usp.br/index.php?id=openstereo. If so, I can try to reproduce the issue on my machine.   

Ronald

> 
> many thanks
> 
> Carlos
> 
> 
> 
> 
> 
> from setuptools import setup
> from glob import glob
> 
> import shutil
> shutil.rmtree("build", ignore_errors=True)
> shutil.rmtree("dist", ignore_errors=True)
> 
> APPNAME = 'OpenStereo'
> APP = ['resources/OpenStereo.py']
> VERSION = '0.1.2g' # must be in X.X.X format
> 
> DATA_FILES = ['license/gpl-3.0.txt'] #[glob(r'resources/*')]
> 
> OPTIONS = {
>            'plist':dict(
>            CFBundleName                = 'OpenStereo',
>            CFBundleShortVersionString  = VERSION,
>            CFBundleVersion             = VERSION,
>            CFBundleGetInfoString       = 'OpenStereo, Open-Source
> Structural Geology Analysis',
>            CFBundleExecutable          = 'OpenStereo',
>            CFBundleIdentifier          = "br.usp.igc",
>            NSHumanReadableCopyright    = 'Carlos H. Grohmann'),
> 
>            'argv_emulation': True,
>            'optimize': 1,
>            'compressed': True,
>            'strip': True,
>            'semi_standalone': False,
>            'packages': ['wx'],
>            'dylib_excludes': ['Tcl.framework','Tk.framework'],
>            'resources': ['icons/openstereo_icon_noname_256x256x32.png'],
>            'iconfile': 'icons/openstereo_icon_noname.icns',
>            }
> 
> setup(
>    app=APP,
>    data_files=DATA_FILES,
>    options={'py2app': OPTIONS},
>    setup_requires=['py2app'],
> )
> 
> 
> 
> 
> 
> 
> -- 
> Prof. Carlos Henrique Grohmann - Geologist D.Sc.
> Institute of Geosciences - Univ. of São Paulo, Brazil
> ---
> http://www.igc.usp.br/pessoais/guano
> http://digitalelevation.wordpress.com/
> http://lattes.cnpq.br/5846052449613692 (CV)
> ---
> Twitter: @CarlosGrohmann
> http://carlosgrohmann.tumblr.com/
> ________________
> Can’t stop the signal.
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4788 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20120308/0191a11d/attachment-0001.bin>


More information about the Pythonmac-SIG mailing list