[Python-Dev] Add a -z interpreter flag to execute a zip file

Paul Moore p.f.moore at gmail.com
Thu Jul 12 12:23:12 CEST 2007


On 12/07/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> > Right, but it's supposed to be cross platform, as mentioned in the
> > patch.  This will work on Windows.
>
> But in the description, you said that you do the same on Windows
> by making a file that is both a zip file and a batch file. So my
> approach is also cross-platform, no?

Getting the details of such a batch file header right on Windows is
not easy, not least because there is no "exec" equivalent on Windows.
The following works, but (a) uses 2 processes, and (b) doesn't
preserve the exit code. The first issue is minor, but the second is a
big problem (and one I don't know how to fix).

Also, on Windows, zip-packaged GUI programs could be useful - these
would be executed using "pythonw -z"

> How do you get the -z option to work on Windows? What extension
> do you use, and how is the zipfile created?

The patch suggests using .pyz and adding a default association to the
installer (much like .py and .pyw have). It also offers a script for
building the zipfiles - either as sample code, or to be included with
Python (it's not clear to me).

It's arguable that .pyz files should use pythonw -z, not python -z, as
file extensions are more often useful for clickable programs in the
GUI. You could have two extensions (.pyz and .pzw, maybe) but I'm not
sure it's worth it.

The point here is that the fiddly part (setting sys.path, locating the
main module, etc) is covered by the -z option, deployment
considerations are easier to handle (and hence the exact defaults
supplied are less crucial) once -z is available.

Paul.


More information about the Python-Dev mailing list