Skip to content

Conversation

branchvincent
Copy link

Fixes #1605

A common value for SOURCE_DATE_EPOCH is 0, which unfortunately breaks hatchling:

$ uv init --build-backend=hatch
$ SOURCE_DATE_EPOCH=0 uv build
# ...
  File "/opt/homebrew/Cellar/python@3.13/3.13.4/Frameworks/Python.framework/Versions/3.13/lib/python3.13/zipfile/__init__.py", line 412, in __init__
    raise ValueError('ZIP does not support timestamps before 1980')
ValueError: ZIP does not support timestamps before 1980

This clamps to 1980 instead (same as setuptools and flit-core. poetry also support this but defaults to 2016)

Copy link
Contributor

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


d = datetime.fromtimestamp(get_reproducible_timestamp(), timezone.utc)
# `zipfile.ZipInfo` does not support timestamps before 1980
min_ts = datetime(1980, 1, 1, tzinfo=timezone.utc).timestamp()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check the value first to avoid doing unnecessary work here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid constructing a datetime right? I just hard-coded the timestamp since the logic is simpler to me but lmk what you think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zipfile will fail if SOURCE_DATE_EPOCH is before 1980

2 participants