Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make build reproducible by reading envvar SOURCE_DATE_EPOCH if set #3430

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

Vincent-C
Copy link
Contributor

@Vincent-C Vincent-C commented Nov 30, 2024

As part of the ongoing Reproducible Builds project, packages in Debian/Ubuntu are routinely scanned and tested for build reproducibility. A bug was filed against the pelican package in Debian, so I'm just forwarding the patch that we've applied there to make it build reproducibly, i.e. by attempting to get the current datetime from a standard envvar, SOURCE_DATE_EPOCH, if it's available. Thanks for considering this change!

@Vincent-C Vincent-C force-pushed the reproducible_builds branch from 6ed6730 to e52b20f Compare December 2, 2024 08:26
@justinmayer justinmayer changed the title Make build reproducible by reading envvar SOURCE_DATE_EPOCH if set Make build reproducible by reading envvar SOURCE_DATE_EPOCH if set Dec 2, 2024
Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

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

Hi Vincent! Thank you for the submission. As it turns out, datetime.datetime.utcfromtimestamp() is deprecated, so I made a suggested change. Would you please take a look and let me know your thoughts?

year = datetime.datetime.now().date().year
year = datetime.datetime.utcfromtimestamp(
int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
).year
Copy link
Member

Choose a reason for hiding this comment

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

This change yields the following deprecation warning:

DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC)

Perhaps the following instead?

year = datetime.datetime.fromtimestamp(
    int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), datetime.timezone.utc
).year

See also:

Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

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

I went ahead and made my suggested change so I could include this PR in an imminent new release. Thanks again, Vincent.

@justinmayer justinmayer merged commit 5be013d into getpelican:main Jan 15, 2025
18 checks passed
@justinmayer
Copy link
Member

I just released Pelican 4.11.0, which includes the changes in this pull request.

@Vincent-C
Copy link
Contributor Author

Thank you!

@Vincent-C Vincent-C deleted the reproducible_builds branch January 15, 2025 18:01
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.

2 participants