[PEAK] Packaging peak apps

Phillip J. Eby pje at telecommunity.com
Tue Sep 7 15:06:10 EDT 2004

At 11:24 AM 9/7/04 -0500, Stephen Haberman wrote:

> > Have you tried the latest py2exe?  Apparently version 0.5 uses Python
> > "import from zipfile" facility, so it seems like it should be compatible
> > with PEAK's import facility (although I haven't tried it myself).
>If that doesn't work, I had some free time when I ran into the problem so I
>fixed the zip import bug in Python.
>The bug is:

Ouch; I didn't realize that 'reload()' didn't work with import-from-zip.

However, that bug has a simple patch (dated April 1) that seems to me it 
would fix the issue for PEAK.  Specifically, the fact that reload() is 
broken for PEP 302 imports.

>The original patch was really small, just a 2-line change to import.c to
>pass a loader reference to find_module, but then it turns out the
>zipimport.c was keeping around buffers or some such thing, so the patch got
>larger and more complex and hence less likely to be quickly committed to

Yep; that "two line" patch *should* fix the problem for PEAK+py2exe, 
however.  Unfortunately, there's no easy pure-Python workaround that I see, 
because PEP 302's proposed 'imp.get_loader()' was never implemented.

>If someone in good standing (~cough~ Phillip ~cough~) were to review, okay,
>and put some weight behind the patch, it might make it in to CVS someday. I
>don't know anything about the currently 2.4 release cycle, maybe it is
>already too late for 2.4.

I can't vouch for the other zipimport fixes, I'm afraid, it's outside my 
expertise.  But the failure to use loaders in the PEP 302 support is a 
separate issue, and that fix alone should suffice for PEAK's use of reload, 
because PEAK isn't *really* reloading anything; it's using reload to force 
the built-in import mechanisms to come into play.  Thus, fixing the PEP 302 
issue alone should fix PEAK, even though it won't fix zip-import reloading 
in the general case.

Here's what I recommend:

* File a bug report for the PEP 302 issue (loader not carried through by 
reload function), and assign it to me

* Attach the patches for import.c and test_importhooks.py; leave off 
everything about zip importing.

* Verify that this reduced patch set is correct; i.e. its test case should 
fail under unpatched 2.3 and 2.4, and succeed under patched 2.3 or 2.4.

* I will apply the patch for 2.4 and backport to the 2.3 maintenance 
branch, so that this can go in 2.3.5 as well as 2.4

* File a new bug report that is specific to the zipimport cache issue, 
along with the remaining (and now much smaller) patch set.  Getting 
somebody to look at that should now be a little easier, since it will only 
deal with zipimport and not PEP 302 generally.

That last step isn't necessary for PEAK to support py2exe, though.

More information about the PEAK mailing list