Skip to content

Commit 2aec272

Browse files
committed
Make the project tarball reproducible on Mac OS X.
Use zero modification time in the gzip header instead of current time. Order of tarfile members depends on the os.listdir order, which is arbitrary on Linux, but seems reproducible on Mac OS X.
1 parent b5c1277 commit 2aec272

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

devutils/makesdist

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import os
99
import subprocess
1010
import glob
1111
import tarfile
12+
import gzip
1213

1314
BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
1415
sys.path.insert(0, BASEDIR)
@@ -29,7 +30,8 @@ print "[done]"
2930
tarname = max(glob.glob(BASEDIR + '/dist/*.tar'), key=os.path.getmtime)
3031

3132
tfin = tarfile.open(tarname)
32-
tfout = tarfile.open(tarname + '.gz', 'w:gz')
33+
fpout = gzip.GzipFile(tarname + '.gz', 'w', mtime=0)
34+
tfout = tarfile.open(fileobj=fpout, mode='w')
3335

3436
def fixtarinfo(tinfo):
3537
tinfo.uid = tinfo.gid = 0
@@ -42,5 +44,7 @@ def fixtarinfo(tinfo):
4244
print 'Filter %s --> %s.gz' % (2 * (os.path.basename(tarname),)),
4345
for ti in tfin:
4446
tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti))
47+
48+
tfin.close()
4549
os.remove(tarname)
4650
print "[done]"

0 commit comments

Comments
 (0)