wheel: bdist_wheel is not idempotent

If I run python setup.py build bdist_wheel twice without changing any files, the resulting wheels have binary differences. This seems a bit unexpected given that other archive tools like tar are idempotent. Is there a reason for this? I tested on python 2 and 3.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

from wheel.wheelfile (mentions #143):

def get_zipinfo_datetime(timestamp=None):
    # 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 = int(os.environ.get('SOURCE_DATE_EPOCH', timestamp or time.time()))
    return time.gmtime(timestamp)[0:6]

for existing files, the original modification time is used (so low stability, as they are clobbered by git), and the /RECORD entry in the archive is given the current timestamp. Alternatively, if SOURCE_DATE_EPOCH is specified in the environment, then it will be used as the modification time for all files - so I think you could use that at the moment and have no extra dependencies.

I’m wondering how relevant modification times are in the use of wheels; should the timestamps in the generated archives always be a fixed date? It sounds like the Debian folks are using SOURCE_DATE_EPOCH in their builds (not sure if they’d prefer that over always using the same stamp). For people using git, the modification times aren’t practically meaningful.

I’m inclined to make a PR for:

def get_zipinfo_datetime(timestamp=None):
    # assuming timestamps are irrelevant, so set all dates to the lowest available in zips (_1980-01-01 00:00:00_)
    timestamp = int(os.environ.get('SOURCE_DATE_EPOCH', 315532800))
    return time.gmtime(timestamp)[0:6]