Title: Documented equivalent of `gzip -n` (omit timestamp and original file name) in gzip module
Type: Stage:
Components: Library (Lib) Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: zwol
Priority: normal Keywords:

Created on 2019-11-06 20:06 by zwol, last changed 2019-11-06 20:06 by zwol.

Messages (1)
msg356150 - (view) Author: Zack Weinberg (zwol) * Date: 2019-11-06 20:06
Recent versions of the gzip command-line utility have an option `-n` which causes it to omit the FNAME field of the gzip file header, and write out the MTIME field as zero.  Both of these properties are desirable when constructing reproducible build artifacts (see ).

Right now, the gzip module lets you set MTIME to zero explicitly by passing `mtime=0` to the GzipFile constructor, but this is not documented.  You can avoid writing out a filename by opening the output file yourself:

    with gzip.GzipFile(fileobj=open("foo.gz", "wb"),
                       filename='', mtime=0) as ofp:
        ... write to ofp ...

but that's awkward and, again, not documented.  I'd like to be able to write something like this instead:

    with"foo.gz", mtime=0, record_filename=False) as ofp:

with this being the documented way to achieve the same effect as `gzip -n`.
Date User Action Args
2019-11-06 20:06:31zwolcreate