[Pythonmac-SIG] py2app question: path to included python

Ronald Oussoren ronaldoussoren at mac.com
Wed Jun 7 22:14:29 CEST 2006


On 7-jun-2006, at 21:54, Russell E Owen wrote:

> At 9:28 PM +0200 2006-06-07, Ronald Oussoren wrote:
>> On 7-jun-2006, at 18:31, Russell E. Owen wrote:
>>
>>>
>>> py2app is significantly smarter than py2exe about finding the  
>>> necessary
>>> files. The only hassles on Mac are:
>>> - the need to copy the data files (not a big deal, especially,
>>> apparently, with newer matplotlibs that use smarter paths)
>>> - apparently the need to explicitly specify the FileDialog module  
>>> (that
>>> one caught me off guard)
>>> - also, if one really wants to be safe, one should either delete
>>> os.env["MATPLOTLIBDATA"] or set it to the correct path.
>>
>> To reiterate a point: all of these can be solved by a  
>> recipe ;-) ;-) ;-)
>
> Yes. Once I can upgrade to the current matplotlib I'm looking  
> forward to trying to write that recipe.
>
> But...can dealing with os.env["MATPLOTLIBDATA"] really be part of  
> the recipe? I had assumed not. If it can, any hints on how to do it?

You can do this using prescripts. The recipe for PIL uses one,  
although the one for matplatlib would be a lot easier.

The recipe for matplatlib would be single module in py2app.recipes:

matplotlib.py:
# BOF
from StringIO import StringIO

def check(cmd, mf):
     m = mf.findNode('matplotlib')
     if m is None or m.filename is None:
         return None

     prescript = StringIO("""\
import os
if 'MATPLOTLIBDATA' in os.environ:
     del os.environ['MATPLOTLIBDATA']
""")

     return dict(
            packages=['matplotlib'], # Include the entire package
            prescripts=[prescript],
     )
# EOF


A word of warning, I typed this in mail.app and haven't actually used  
recipes before.

Ronald

>
> -- Russell



More information about the Pythonmac-SIG mailing list