You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add equivalent of gzip -n (omit timestamp and original file name) to tarfile module's auto-compression support #82907
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2019-11-06.20:12:04.355>labels= []
title="Add equivalent of `gzip -n` (omit timestamp and original file name) to tarfile module's auto-compression support"updated_at=<Date2019-11-06.20:12:04.355>user='https://bugs.python.org/zwol'
Right now, it's possible to get the gzip module to do the same thing (it's not documented, but it's possible; see bug 38725) but, as far as I can tell, if you use tarfile's "w:gz" or "w|gz" modes you will always get a timestamp and a filename in the output. Please add w[:|]gzn, or something like that, that behaves as-if the output were piped through gzip -n.
(It might make sense to remove the manual creation of a gzip file header from the tarfile module at the same time; it looks like this code predates the addition of the gzip module to the stdlib.)
Activity
zwol commentedon Nov 6, 2019
Recent versions of the gzip command-line utility have an option
-nwhich 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, it's possible to get the
gzipmodule to do the same thing (it's not documented, but it's possible; see bug 38725) but, as far as I can tell, if you usetarfile's "w:gz" or "w|gz" modes you will always get a timestamp and a filename in the output. Please addw[:|]gzn, or something like that, that behaves as-if the output were piped throughgzip -n.(It might make sense to remove the manual creation of a gzip file header from the tarfile module at the same time; it looks like this code predates the addition of the gzip module to the stdlib.)
dahlend commentedon Jan 20, 2023
The "bug 38725" in the original comment now directs to this issue:
#82906
serhiy-storchaka commentedon May 21, 2026
The
mtimeparameter fortarfile.open()was added in #75707. Now we only need to specially document the 0 value, like in the gzip module documentation.omkar-334 commentedon May 22, 2026
hi @serhiy-storchaka can I work on this
serhiy-storchaka commentedon May 22, 2026
Go ahead, @omkar-334.
Merge branch 'main' into pythongh-82907-tarfile-mtime0-doc
gh-82907: Document mtime=0 for reproducible tarfile gzip output (GH-1…
[3.15] gh-82907: Document mtime=0 for reproducible tarfile gzip output (