Skip to content

Commit bc61e44

Browse files
committed
ZipFile.writestr now respect SOURCE_DATE_EPOCH
1 parent e69ff34 commit bc61e44

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/zipfile/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,10 @@ def writestr(self, zinfo_or_arcname, data,
19041904
if isinstance(data, str):
19051905
data = data.encode("utf-8")
19061906
if not isinstance(zinfo_or_arcname, ZipInfo):
1907+
time_ = os.environ.get('SOURCE_DATE_EPOCH') or time.time()
1908+
date_time = time.gmtime(time_)[:6]
19071909
zinfo = ZipInfo(filename=zinfo_or_arcname,
1908-
date_time=time.localtime(time.time())[:6])
1910+
date_time=date_time)
19091911
zinfo.compress_type = self.compression
19101912
zinfo.compress_level = self.compresslevel
19111913
if zinfo.filename.endswith('/'):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``ZipFile.writestr`` now respect SOURCE_DATE_EPOCH, that distributions can
2+
set centrally and have build tools consume this in order to produce
3+
reproducible output.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy