This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2019-11-06 20:06 by zwol, last changed 2022-04-11 14:59 by admin.

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 https://reproducible-builds.org/ ).

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 gzip.open("foo.gz", mtime=0, record_filename=False) as ofp:

with this being the documented way to achieve the same effect as `gzip -n`.
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82906
2019-11-06 20:06:31zwolcreate