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

Add support for reproducible builds #2

Merged
merged 9 commits into from
Sep 10, 2023
Merged

Add support for reproducible builds #2

merged 9 commits into from
Sep 10, 2023

Conversation

adamws
Copy link
Contributor

@adamws adamws commented Sep 6, 2023

See [1] for more info about reproducible builds. In case of zip files we need to adjust timestamps. After this change, each built zip archive will have same hash (as long as packaged files do not change)

[1] https://hatch.pypa.io/latest/config/build/#reproducible-builds

See [1] for more info about reproducible builds. In case of zip files we
need to adjust timestamps. After this change, each built zip archive
will have same hash (as long as packaged files do not change)

[1] https://hatch.pypa.io/latest/config/build/#reproducible-builds
Copy link
Owner

@dairiki dairiki left a comment

Choose a reason for hiding this comment

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

@adamws Thank you for the PR! I think adding the capability of reproducible builds is a valuable addition.

Currently, this code fails our CI tests, due to various style nits.

Here are some comments which call out those nits, and add a few more.

The most important has to do with not reading whole files into memory in ZipArchive.add_file.

(If you'd rather I fix these, say so. I don't want to mess with your code, however, if you feel like addressing these issues.)

hatch_zipped_directory/builder.py Outdated Show resolved Hide resolved
hatch_zipped_directory/builder.py Outdated Show resolved Hide resolved
hatch_zipped_directory/builder.py Outdated Show resolved Hide resolved
hatch_zipped_directory/builder.py Outdated Show resolved Hide resolved
hatch_zipped_directory/builder.py Outdated Show resolved Hide resolved
tests/test_builder.py Outdated Show resolved Hide resolved
hatch_zipped_directory/builder.py Outdated Show resolved Hide resolved
tests/test_builder.py Outdated Show resolved Hide resolved
tests/test_builder.py Outdated Show resolved Hide resolved
@adamws
Copy link
Contributor Author

adamws commented Sep 10, 2023

@adamws Thank you for the PR! I think adding the capability of reproducible builds is a valuable addition.

Currently, this code fails our CI tests, due to various style nits.

Here are some comments which call out those nits, and add a few more.

The most important has to do with not reading whole files into memory in ZipArchive.add_file.

(If you'd rather I fix these, say so. I don't want to mess with your code, however, if you feel like addressing these issues.)

Hello, this code is derived from my project: https://github.com/adamws/hatch-kicad
Looking at hatch-zipped-directory code helped me to understand how to write hatch plugins so I wanted to give something back. You are welcome to take this patch and modify it.

adamws and others added 7 commits September 10, 2023 13:35
Restore the behavior (from ZipFile.writestr) of setting the timestamp
to the current time for non-reproducible builds.
Ripped from hatchling's WheelArchive.add_file:

Popular VCSs only track whether a file is executable or not. The exact
permissions can vary on systems with different umasks. Normalizing to
644 (non executable) or 755 (executable) makes builds more
reproducible.
@dairiki
Copy link
Owner

dairiki commented Sep 10, 2023

You are welcome to take this patch and modify it.

@adamws Thank you. I think I've addressed the issues raised in my comments.

Again, thank you for the PR. I think it's a good addition.

@dairiki dairiki merged commit f0f4d4b into dairiki:master Sep 10, 2023
9 checks passed
@dairiki
Copy link
Owner

dairiki commented Sep 10, 2023

Released in 0.1.0b4.

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