[Pythonmac-SIG] [Numpy-discussion] Packaging numpy with py2app

Bob Ippolito bob at redivi.com
Tue Jul 18 07:15:06 CEST 2006


On Jul 17, 2006, at 10:01 PM, Josh Marshall wrote:

> Thanks Bob,
>
> On 18/07/2006, at 2:01 PM, Bob Ippolito wrote:
>> To do "includes", you need to manipulate the modulegraph instance.  
>> Take a look at the docutils recipe for an example. 'packages' is  
>> in the return value because that need to be dealt with by py2app,  
>> not modulegraph.
> Can you change the recipe for matplotlib to be:
>
> def check(cmd, mf):
>     m = mf.findNode('matplotlib')
>     if m is None or m.filename is None:
>         return None
>     mf.import_hook('pytz.zoneinfo', m, ['UTC'])
>     return dict(
>         packages = ['matplotlib']
>     )
>
>
> This does the trick with no workarounds.
>
> If anyone needs to actual work with the plotting of time-zone  
> relative dates in matplotlib in embedded Cocoa, it'll die. However,  
> the likelihood of this occurring is low, but for future reference  
> for the Googlers of the future; add the time-zones you need to the  
> list in import_hook, ie ['UTC', 'Australia.Sydney'].

If you were actually doing that, you should write the imports  
yourself. The right place to put that metadata is in your code with  
import statements, because that's cross-platform and cross-packager.  
py2exe and cx_Freeze will understand import statements too.

>> Applications are usually distributed compressed, the on-disk size  
>> isn't too much of a concern for most people...
>
> True, I just compressed the .app and it shrunk from 40 MB to 14, so  
> no problems there. The other thing to get down the compressed size  
> is for me to figure out how to exclude stuff I don't need. The  
> question does stand though, how would I go about including the  
> package 'scipy', but omitting 'scipy.weave'?

You can't do that so long as scipy is wholly included with the  
packages option. The packages option does "cp -r" effectively, I'm  
not going to complicate it for this use case. I might accept a patch  
if it wasn't too horrible, but the effort is better spent making  
scipy work in a zip archive.

> My other concern was getting around to doing this as a universal  
> binary and have an enormous file. What sort of file size increases  
> am I looking at? I presume it'll just be the libraries that double  
> in size, and the Python code should remain the same?

The file size increase is what you'd expect -- a bit less than  
double. x86 code is somewhat smaller than PPC because it has more  
instructions to choose from and they're variable length.

The Python code is shared, but that's very rarely the bulk. Plus it  
gets compressed unless explicitly excluded with packages, where  
platform code isn't compressed.

-bob



More information about the Pythonmac-SIG mailing list