Update to PEP 441 from Paul More: swap pack() args, default archive name, support open streams.

This commit is contained in:
Guido van Rossum 2015-02-24 10:34:33 -08:00
parent 4cf8410bc9
commit 17dfaa547e
1 changed files with 15 additions and 11 deletions

View File

@ -90,17 +90,19 @@ Module Interface
The zipapp module will provide the following functions: The zipapp module will provide the following functions:
``pack(target, directory, interpreter=None, main=None)`` ``pack(directory, target=None, interpreter=None, main=None)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Writes an application archive called *target*, containing the Writes an application archive called *target*, containing the contents
contents of *directory*. If *interpreter* is specified, it will of *directory*. The *target* can be a filename, or a file-like object
be written to the start of the archive as a shebang line and the file (which must be open for writing in bytes mode), or None (which means
will be made executable (if no interpreter is specified, the shebang use the name of *directory* with ``.pyz`` appended). If *interpreter*
line will be omitted). If the directory contains no ``__main__.py`` is specified, it will be written to the start of the archive as a
file, the function will construct a ``__main__.py`` which calls the shebang line and the file will be made executable (if no interpreter
function specified in the *main* argument (which should be in the is specified, the shebang line will be omitted). If the directory
form ``'pkg.mod:fn'``). contains no ``__main__.py`` file, the function will construct a
``__main__.py`` which calls the function specified in the *main*
argument (which should be in the form ``'pkg.mod:fn'``).
It is an error to specify *main* if the directory contains a It is an error to specify *main* if the directory contains a
``__main__.py``, or to omit *main* when there is no ``__main__.py`` ``__main__.py``, or to omit *main* when there is no ``__main__.py``
@ -118,7 +120,9 @@ If there is no shebang, the function returns ``None``.
Modifies the *archive*'s shebang line to contain the specified Modifies the *archive*'s shebang line to contain the specified
interpreter, and writes the updated archive to *new_archive*. If the interpreter, and writes the updated archive to *new_archive*. If the
*interpreter* is ``None``, removes the shebang line. *interpreter* is ``None``, removes the shebang line. The
*new_archive* argument can be a filename, or a file-like object open
for writing in byte mode.
Command Line Usage Command Line Usage
------------------ ------------------