summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Coraor <nate@bx.psu.edu>2016-02-01 14:58:47 -0500
committerNate Coraor <nate@bx.psu.edu>2016-02-01 14:58:47 -0500
commit9b52a951828a0c1255684a22906f57dddb0d9f7c (patch)
treecd6779a5333760a4ffc75a049c02e92226db2f99
parent145abb4ac83643011ab60988635d63d2616d932e (diff)
downloadwheel-9b52a951828a0c1255684a22906f57dddb0d9f7c.tar.gz
Additional changes to reproducible wheel files from Barry Warsaw and Debian:
- Use a more general `SOURCE_DATE_EPOCH` env variable (rather than a wheel-specific one) - Use UTC time to avoid reproducibility errors on systems with differing timezones
-rw-r--r--wheel/archive.py6
-rw-r--r--wheel/test/test_wheelfile.py2
2 files changed, 4 insertions, 4 deletions
diff --git a/wheel/archive.py b/wheel/archive.py
index 42ffee6..bf06767 100644
--- a/wheel/archive.py
+++ b/wheel/archive.py
@@ -36,11 +36,11 @@ def make_wheelfile_inner(base_name, base_dir='.'):
# Some applications need reproducible .whl files, but they can't do this
# without forcing the timestamp of the individual ZipInfo objects. See
# issue #143.
- timestamp = os.environ.get('WHEEL_FORCE_TIMESTAMP')
+ timestamp = os.environ.get('SOURCE_DATE_EPOCH')
if timestamp is None:
date_time = None
else:
- date_time = time.localtime(int(timestamp))[0:6]
+ date_time = time.gmtime(int(timestamp))[0:6]
# XXX support bz2, xz when available
zip = zipfile.ZipFile(open(zip_filename, "wb+"), "w",
@@ -52,7 +52,7 @@ def make_wheelfile_inner(base_name, base_dir='.'):
def writefile(path, date_time):
if date_time is None:
st = os.stat(path)
- mtime = time.localtime(st.st_mtime)
+ mtime = time.gmtime(st.st_mtime)
date_time = mtime[0:6]
zinfo = zipfile.ZipInfo(path, date_time)
with open(path, 'rb') as fp:
diff --git a/wheel/test/test_wheelfile.py b/wheel/test/test_wheelfile.py
index 561f578..1d35ec4 100644
--- a/wheel/test/test_wheelfile.py
+++ b/wheel/test/test_wheelfile.py
@@ -115,7 +115,7 @@ def test_zipfile_timestamp():
fp.write(filename + '\n')
zip_base_name = os.path.join(tempdir, 'dummy')
# The earliest date representable in TarInfos, 1980-01-01
- with environ('WHEEL_FORCE_TIMESTAMP', '315576060'):
+ with environ('SOURCE_DATE_EPOCH', '315576060'):
zip_filename = wheel.archive.make_wheelfile_inner(
zip_base_name, tempdir)
with readable_zipfile(zip_filename) as zf: