[Pythonmac-SIG] Zope py2app, some progress

Bob Ippolito bob at redivi.com
Thu Feb 10 08:38:33 CET 2005


On Feb 10, 2005, at 2:25 AM, Roger Binns wrote:

>> I'd like to see that pie slice for the Mac OS X build to shrink even 
>> further..
>
> You aren't satisfied with being the smallest amount of code already ?-)

I don't really care what the other platforms look like, but I want 
py2app setup files to be as compact as possible so that the barrier to 
entry is very low, and so that it's easy enough to shrug off distutils 
when that makes sense (i.e. py2applet).

>> I took at a look at your setup.py, and it looks a fair amount of it 
>> doesn't need to be specified:
>
> More accurately you are looking at code that has evolved over two years
> and for the Mac bits used to support BundleBuilder and has to build
> the 10.2 and 10.3 packages differently.
>
>> Other than removing whitespace, I think that's about all I can do to 
>> make your setup shorter :)
>
> I'm not particularly concerned with how long it is.  The point of
> the original slides was how little work it is to take a full featured
> Python graphical application and distribute it as a native app without
> the user knowing or caring that it is in Python or having to install
> any pre-requisites.

Which is rather impressive, considering how stupid the tools are -- but 
it doesn't really need to take much code at all.  For applications 
organized in a sane manner, py2app can do it with just a drag+drop of 
your main script and any data files you use.  I'll probably add code to 
be able to pull a __version__ out of your main script, since I have 
that written for something else anyway.

> Incidentally a number of people over time have taken copies of that
> script for their own projects.
>
> The biggest problem on Mac at the moment is having to distribute
> two versions (one for 10.2 and one for 10.3).  Second to that is
> the sheer size of the download.

So don't bother building a 10.3 version.  The 10.2 version should work 
fine.

> Platform     DownloadSize     InstalledSize
>
> Windows         7.4MB                27MB
> Linux          10.5MB                30MB
> Panther        14.9MB                40MB
>
> The good news is I found the cause and fix.  A whole bunch of the
> wxPython/wxWidgets libraries don't respond to strip or have been
> stripped.  However running "strip -x" does remove a whole bunch
> more gunk that plain "strip" doesn't.  (IIRC cx-Freeze runs strip on 
> executable files/libraries automatically.)
>
> Adding another Mac specific line (:-) to makedist.py to automatically
> run the strip reduces the download to 10.4MB and the installed size
> to 20.6MB.

Did you know py2app had a --strip option, which does strip -x -S?  It's 
had this as long as I can remember, but it's gone now :)  I think even 
bundlebuilder had it, but it may have had more naive strip options.

0.1.8 (svn trunk) has --strip as default, so --strip is a no-op and 
there's now a --no-strip to turn it off.

> Note also that both Windows and Linux don't compress the contents
> of the zip file containing all the .pyo files.  py2app also looks
> like it does a way better job of excluding unneeded .pyo files.

I decided to compress always and by default because CPU is cheap and IO 
is not.. I couldn't find a compelling reason to use an uncompressed 
zip, just like I decided not to bother stripping.  If you want to run 
your app under gdb, you should probably be using an alias bundle...

> Incidentally I did find a gross hack to work around the py2app
> bug of not handling the optimise option.  Stripping out the doc 
> strings saves over 3MB of compressed size, and aren't useful
> in the binary end user distribution anyway.

It's close(r) to working in svn trunk, but I don't think it actually 
works just yet.

-bob



More information about the Pythonmac-SIG mailing list