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

Bob Ippolito bob at redivi.com
Wed Jul 19 02:57:29 CEST 2006


On Jul 18, 2006, at 5:32 PM, Josh Marshall wrote:

> Thanks for the info on how the various recipes work, Bob. Very  
> helpful.
>
> On 19/07/2006, at 9:28 AM, Bob Ippolito wrote:
>> The recipe mechanism doesn't allow for it because it doesn't
>> generally make sense. There are very few packages that can find
>> their resources in an alternative manner. I'm not totally opposed
>> to adding another feature to support that use case, but throwing it
>> directly in the resources dir seems like a bad idea to do
>> automatically from a recipe. The files should sit under some kind
>> of matplotlib hierarchy. It would be nicer to see matplotlib just
>> figure out how to make their app work from a zip... pygame does,
>> and it has fonts and icons.
>
> I think matplotlib can access files inside the zip, since it searches
> inside the following directories upon startup and is frozen-aware.
>
> MatplotlibEmbedSample.app/Contents/Resources/lib/python2.4/site-
> packages.zip/matplotlib/mpl-data
> MatplotlibEmbedSample.app/Contents/mpl-data
> MatplotlibEmbedSample.app/Contents/Resources/mpl-data
>
> So I have been attempting to put the data files in the zip.
>
>> loader_files puts data files *in the zip*
>
> Indeed it does. When I use the following recipe: (noting that the
> recipe's filename can't be "matplotlib.py", I've been using
> "matplotlib_recipe.py"):
>
> def check(cmd, mf):
>      m = mf.findNode('matplotlib')
>      if m is None or m.filename is None:
>          return None
>
>      import matplotlib, glob, os
>      mpl_datapath = matplotlib.get_data_path()
>      mpl_datafilelist = glob.glob(mpl_datapath + r'/*')
>
>      # only include individual files from the mpl-data directory
>      # this should exclude directories, which should only be
> Matplotlib.nib
>      mpl_datafilelist = [mpl_file for mpl_file in mpl_datafilelist
>                          if os.path.isfile(mpl_file)]
>
>      mf.import_hook('pytz.zoneinfo', m, ['UTC'])
>      mf.import_hook('matplotlib.numerix', m, ['random_array'])
>      return dict(
>          loader_files = [
>              ('matplotlib', mpl_datafilelist),
>          ],
>      )
>
> The data files then get put in the matplotlib directory in the zip.
> However, matplotlib searches in the mpl-data directory *inside* the
> matplotlib directory, as shown in the search paths above.
>
> I have not been able to find a way to include a directory within the
> matplotlib directory. If I use
>          loader_files = [
>              ('matplotlib/mpl-data', mpl_datafilelist),
>          ],
> py2app barfs when trying to copy the files since the directory
> doesn't exist. Any ideas Bob?

This should work in svn (r13). You can easily run the development  
version straight from a svn checkout:

svn co http://svn.pythonmac.org/py2app/py2app/trunk py2app
cd py2app
python setup.py develop

That'll set it up such that the "installed" py2app is actually what's  
sitting in your svn checkout. You can make changes without re- 
installing or anything.

-bob


More information about the Pythonmac-SIG mailing list