[Pythonmac-SIG] py2app and PIL question

Bob Ippolito bob at redivi.com
Thu Nov 17 01:57:25 CET 2005


On Nov 16, 2005, at 4:50 PM, Chris Jerdonek wrote:

> On Nov 16, 2005, at 2:14 PM, Bob Ippolito wrote:
>
>>>>> class FreeTypeFont:
>>>>>      "FreeType font wrapper (requires _imagingft service)"
>>>>>
>>>>>      def __init__(self, file, size, index=0, encoding=""):
>>>>>          # FIXME: use service provider instead
>>>>>          import _imagingft
>>>>> (121)   self.font = _imagingft.getfont(file, size, index,  
>>>>> encoding)
>>>>
>>>> Looks like it's trying to find a font or something that isn't where
>>>> PIL expects it to be... you sure you added all the data files that
>>>> you're using?
>>>
>>>
>>> Is there a way for me to find out what data files I'm using?
>>> Apparently the font normally gets loaded through PIL's _imagingft
>>> module, but the _imagingft module seems weird.  Take a look at it
>>> below (it even mentions py2app).  Any idea what this means -- how to
>>> work around it?
>>
>> no, there isn't really a way to find out what data files you're using
>> other than to look hard at the source code.. unless you ktrace the
>> process and look at all the NAMI or something.
>>
>> The code you're looking at isn't _imagingft, it's a stub to load it.
>> _imagingft is an extension, written in C.
>
> Is there a way I could modify the code to write these font objects  
> to a
> file?  (The same font is needed every time the program is run.)  Then,
> before running py2app, I could change the code to load these font
> objects directly -- instead of going through the usual _imagingft
> binary extension module.
>
> Also, is my understanding correct that py2app can't detect these
> dependencies because they appear in a binary extension as opposed to a
> python module?

py2app can't detect data dependencies, period.  You need to figure  
out what data files you need, and explicitly specify them.  The  
referenced code sure looks like it was looking for a data file, and I  
don't recall PIL having any data files in its distribution.  As far  
as I can tell, this font is your data file and you need to specify it  
in your setup.py... nothing I could do to py2app would be able to  
find it for you automatically.

-bob



More information about the Pythonmac-SIG mailing list