Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions sipbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,23 @@ def build_wheel(self, wheel_directory):
saved_cwd = os.getcwd()
os.chdir(wheel_build_dir)

from zipfile import ZipFile, ZIP_DEFLATED
import time
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED

# Ensure reproducible wheel file timestamps
epoch = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
zip_timestamp = time.gmtime(epoch)[:6]

with ZipFile(wheel_path, 'w', compression=ZIP_DEFLATED) as zf:
for dirpath, _, filenames in os.walk('.'):
for filename in filenames:
# This will result in a name with no leading '.'.
name = os.path.relpath(os.path.join(dirpath, filename))

zf.write(name)
zi = ZipInfo(name, zip_timestamp)

with open(name, 'rb') as f:
zf.writestr(zi, f.read())

os.chdir(saved_cwd)

Expand Down