At 10:35 PM +0100 1/16/07, Ronald Oussoren wrote:
>On 16 Jan, 2007, at 22:20, Russell E Owen wrote:
>
>>My py2app-bundled Mac application recently started failing with "no
>>module named email.Util" when trying to display images. It turns out
>>pyfits uses urllib which uses email.Util, which apparently has been
>>renamed email.util with some kind of clever lazy import code so one can
>>still use email.Util. Apparently the cleverness is too much for py2app's
>>module finder.
>
>The cleverness doesn't use the import statement, which is why py2app 
>doesn't understand this. Py2exe will suffer from the same problem as 
>it uses a simular algorithm.
>
>>Anyway, the easy workaround is to specify email.Util as a necessary
>>module to import. But I'll report a python bug or submit a urllib patch.
>
>It's unlikely that this will be fixed in Python itself, we'll have 
>to add a recipe to py2app that works around this problem. I don't 
>have time to look at this right now, patches are obviously welcome 
>:-)

I submitted a patch for python (changing email.Utils->email.utils in 
urllib, with similar patches for urllib2 and smtplib). But I agree 
that a recipe for py2app would be very good, since some people will 
run py2app against 2.5.

The following recipe seems to work, but I don't know if it's really 
the right way to go. It is based on extrapolating from the current 
recipes. None of them seem to do the same job and I've not found any 
docs on writing recipes:

def check(cmd, mf):
        m = mf.findNode('email')
        if m is None or m.filename is None:
                return None
        oldNames = [
                'base64MIME',
                'Charset',
                'Encoders',
                'Errors',
                'Generator',
                'Header',
                'Iterators',
                'Message',
                'MIMEAudio',
                'MIMEBase',
                'MIMEImage',
                'MIMEMessage',
                'MIMEMultipart',
                'MIMENonMultipart',
                'MIMEText',
                'Parser',
                'quopriMIME',
                'Utils',
                'message_from_string',
                'message_from_file',
        ]
        oldModules = ["email." + name for name in oldNames]

        return dict(
                modules = oldModules,
        )

Regards,

-- Russell
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to