[Python-Dev] Request for Pronouncement: PEP 441 - Improving Python ZIP Application Support

Brett Cannon brett at python.org
Tue Feb 24 21:41:27 CET 2015


On Tue Feb 24 2015 at 3:21:30 PM Paul Moore <p.f.moore at gmail.com> wrote:

> On 24 February 2015 at 18:58, Guido van Rossum <guido at python.org> wrote:
> > Why no command-line equivalent for the other two methods?  I propose the
> > following interface: if there's only one positional argument, we're
> asking
> > to print its shebang line; if there are two and the input position is an
> > archive instead of a directory, we're copying.  (In the future people
> will
> > want an option to print more stuff, e.g. the main function or even a full
> > listing.)
>
> Thinking about this, there are 3 main uses:
>
> 1. Create an archive
> 2. Print the shebang
> 3. Change the shebang
>
> Of these, (1) is the crucial one.
>
> Basic usage should be
>
>     python -m zipapp mydir [-o anothername.pyz] [-p interpreter] [-m
> entry:point]
>
> This zips up mydir to create an archive mydir.pyz. Options to change
> the target name, set a shebang line (side note: --python/-p or
> --interpreter/-i?) and set the entry point,
>
> I see this as pretty non-negotiable, this is the key use case that
> needs to be as simple as possible.
>
> To print the shebang, we could use
>
>     python -m zipapp myapp.pyz --show
>
> This allows for future expansion by adding options, although most
> other things you might want to do (list the files, display
> __main__.py) can be done with a standard zip utility. I'm not keen on
> the option name --show, but I can't think of anything substantially
> better.
>
> To modify an archive could be done using
>
>     python -m zipapp old.pyz new.pyz [-p interpreter]
>
> Default is to strip the shebang (no -p option). There's no option to
> omit the target and do an inplace update because I feel the default
> action (strip the shebang from the existing file with no backup) is
> too dangerous.
>
> To be explicit, "python -m zipapp app.pyz" will fail with a message
> "In-place editing of python zip applications is not supported".
>
> That seems to work.
>
> Open questions:
>
> 1. To create an archive, use -o target for an explicit target name, or
> just "target". The former is more conventional, the latter consistent
> with modification. Or we could make modification use a (mandatory) -o
> option.
>

EIBTI suggests requiring the -o. Pragmatic suggests just [in] [out] and use
context based on what kind of thing [in] points at as well as whether -p is
specified and whether it has an argument, which is the most minimal UX you
can have. Question is whether you can screw up by specifying the wrong
thing somehow (you might have to require that [out] doesn't already exist
to make it work).


> 2. -p/--python or -i/--interpreter for the shebang setting option
>

Since you are going to be using `python -m pyzip` then -i/--interpreter is
less redundant-looking on the command-line.


> 3. What to call the "show the shebang line" option


As suggested above, -p w/o an argument could do it, otherwise --show or
--info seems fine (I like --shebang, but that will probably be tough on
non-English speakers).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150224/950ba715/attachment-0001.html>


More information about the Python-Dev mailing list