GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-91279: ZipFile.writestr now respect SOURCE_DATE_EPOCH by Wulian233 · Pull Request #124435 · python/cpython

Conversation

@Wulian233

@Wulian233 Wulian233 commented Sep 24, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

No SOURCE_DATE_EPOCH environment variable makes pip installing a package generate non-reproducible build artifacts.

SOURCE_DATE_EPOCH is a standardised environment variable that distributions can set centrally and have build tools consume this in order to produce reproducible output. In practice, specifies the last modification of something, usually the source code, measured in the number seconds since the Unix epoch, ie. .SOURCE_DATE_EPOCHJanuary 1st 1970, 00:00:00 UTC

See https://reproducible-builds.org/docs/source-date-epoch/
details in issue: #91279

  • Issue: ZipFile.writestr should respect SOURCE_DATE_EPOCH #91279

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ghost

ghost commented Sep 24, 2024 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Sep 24, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 24, 2024
ZipFile.writestr should respect SOURCE_DATE_EPOCH #91279
Closed
ZeroIntensity
ZeroIntensity reviewed Sep 24, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2024-09-24-20-25-52.gh-issue-91279.9oMUwW.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity

ZeroIntensity commented Sep 24, 2024

Copy link
Copy Markdown
Member

Could you add a test for this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233

Wulian233 commented Sep 24, 2024

Copy link
Copy Markdown
Contributor Author

Could you add a test for this?

Yes, this change should also be synchronized in the tests.

Note: zipfile.writestr is not a function, it is the zipfile.ZipFile.writestr method

https://github.com/python/cpython/blob/main/Lib/test/test_zipfile/_path/test_path.py#L668-L668

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity

ZeroIntensity commented Sep 24, 2024

Copy link
Copy Markdown
Member

Oh! TIL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233
Wulian233 requested a review from jaraco as a code owner September 25, 2024 11:33
ZeroIntensity
ZeroIntensity reviewed Sep 25, 2024
View reviewed changes
Comment thread Lib/test/test_zipfile/_path/test_path.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233
Wulian233 marked this pull request as draft September 25, 2024 13:40
@bedevere-app bedevere-app Bot removed the awaiting review label Sep 25, 2024
jaraco
jaraco reviewed Sep 25, 2024
View reviewed changes
Comment thread Lib/test/test_zipfile/_path/test_path.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233
Wulian233 force-pushed the SOURCE_DATE_EPOCH branch from 115adc6 to 6a19ed1 Compare September 26, 2024 11:36
Wulian233
Wulian233 commented Sep 27, 2024
View reviewed changes
Comment thread Lib/test/test_zipfile/test_core.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233
Wulian233 marked this pull request as ready for review September 27, 2024 12:56
@bedevere-app bedevere-app Bot added the awaiting review label Sep 27, 2024
ZeroIntensity
ZeroIntensity approved these changes Sep 27, 2024
View reviewed changes

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Sep 27, 2024
@Wulian233 Wulian233 mentioned this pull request Nov 2, 2024
gh-123424: add ZipInfo._for_archive to set suitable default properties #123429
Merged
jaraco
jaraco requested changes Dec 29, 2024
View reviewed changes
Comment thread Lib/test/test_zipfile/test_core.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting core review labels Dec 29, 2024
@bedevere-app

bedevere-app Bot commented Dec 29, 2024

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233
Wulian233 force-pushed the SOURCE_DATE_EPOCH branch from b7ca376 to 3126ac3 Compare December 30, 2024 11:44
@Wulian233 Wulian233 closed this Dec 30, 2024
@Wulian233
Wulian233 force-pushed the SOURCE_DATE_EPOCH branch from 3126ac3 to 81376fe Compare December 30, 2024 11:47
@Wulian233
finish
693e66f
@Wulian233 Wulian233 reopened this Dec 30, 2024
@Wulian233

Wulian233 commented Dec 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Dec 30, 2024
@bedevere-app

bedevere-app Bot commented Dec 30, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

@jaraco: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from jaraco December 30, 2024 12:06
@Wulian233
Update __init__.py
d07b4ad
jaraco
jaraco requested changes Jan 1, 2025
View reviewed changes
Comment thread Lib/zipfile/__init__.py Outdated
# gh-91279: Set the SOURCE_DATE_EPOCH to a specific timestamp
epoch = os.environ.get('SOURCE_DATE_EPOCH')
get_time = int(epoch) if epoch else time.time()
self.date_time = time.gmtime(get_time)[:6]

@jaraco jaraco Jan 1, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm a little uneasy that time.localtime() is now replaced by time.gmtime(). That means that the value will change depending on the local time zone of the machine running the code, which may not be adequately exercised in the code. Are there existing tests that validate that gmtime is the correct usage here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Wulian233 Wulian233 Jan 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I checked the documentation. Should time.gmtime return UTC time and not change with time zones? time.localtime says "Like gmtime() but converts to local time"

https://docs.python.org/3.14/library/time.html#time.gmtime

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jaraco jaraco Jan 1, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

What I mean is that this change alters the behavior for all cases. The issue doesn't make mention of gmtime and only mentions localtime in relation to the current implementation. What's the motivation for changing it?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Wulian233 Wulian233 Jan 1, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sorry, I see that I was mistaken. To implement this PR I originally thought it was necessary to change it to gmtime, but in fact, this modification should not have been made😥

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot removed the awaiting change review label Jan 1, 2025
@bedevere-app

bedevere-app Bot commented Jan 1, 2025

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting changes label Jan 1, 2025
@Wulian233
using time.localtime
54a7116
@Wulian233

Wulian233 commented Jan 1, 2025

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

Sorry again for the inconvenience

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Jan 1, 2025
@bedevere-app

bedevere-app Bot commented Jan 1, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@jaraco: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from jaraco January 1, 2025 07:26
jaraco
jaraco approved these changes Jan 20, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Jan 20, 2025
@jaraco
jaraco merged commit 5d57959 into python:main Jan 20, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 20, 2025
@Wulian233
Wulian233 deleted the SOURCE_DATE_EPOCH branch January 20, 2025 21:09
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 21, 2025
@Wulian233 @srinivasreddy
pythongh-91279: ZipFile.writestr now respect SOURCE_DATE_EPOCH (pytho…
a3b40da
…n#124435)
@Wulian233 Wulian233 mentioned this pull request May 20, 2025
gh-134261: ZipFile - Don't rely on local time for reproducible builds & tests #134264
Merged
@Leseratte10 Leseratte10 mentioned this pull request Jun 28, 2026
zipinfo: strict_timestamps=False fails in combination with SOURCE_DATE_EPOCH #152445
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jaraco jaraco jaraco approved these changes
@ZeroIntensity ZeroIntensity ZeroIntensity approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Wulian233 @ZeroIntensity @jaraco
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.