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 sdist determinisitic by setting gzip mtime to 0 #870

Closed
wants to merge 1 commit into from

Conversation

achow101
Copy link

@achow101 achow101 commented Feb 6, 2019

A GZip file contains a timestamp with it's last modification time. This timestamp by default is the current time which will make poetry build produce non-deterministic sdist archives. To make sdist archives deterministic, this timestamp must be set to a fixed time. So this PR sets that time to 0.

  • Added tests for changed code.
  • (N/A) Updated documentation for changed code.

Copy link
Contributor

@brycedrennan brycedrennan left a comment

Choose a reason for hiding this comment

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

Interesting. Can you fix the formatting?

@brycedrennan brycedrennan added the kind/feature Feature requests/implementations label Aug 17, 2019
@achow101
Copy link
Author

Interesting. Can you fix the formatting?

Done.

Copy link
Contributor

@brycedrennan brycedrennan left a comment

Choose a reason for hiding this comment

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

Thanks!

@brycedrennan brycedrennan self-requested a review August 18, 2019 03:52
@stale
Copy link

stale bot commented Nov 13, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 13, 2019
@finswimmer finswimmer self-requested a review December 5, 2019 20:09
@@ -64,7 +64,7 @@ def build(self, target_dir=None): # type: (Path) -> Path
target = target_dir / "{}-{}.tar.gz".format(
self._package.pretty_name, self._meta.version
)
gz = GzipFile(target.as_posix(), mode="wb")
gz = GzipFile(target.as_posix(), mode="wb", mtime=0)
Copy link
Member

Choose a reason for hiding this comment

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

Hello @achow101,

thanks a lot for your contribution. Fixing this looks necessary to me. Are there any reasons for settings the mtime to 0 and not to the current time via time.time()?

fin swimmer

Copy link
Author

Choose a reason for hiding this comment

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

It's literally the whole point of this PR. A fixed time is needed otherwise the resulting archive is non-deterministic. Setting to time.time() means that the timestamp will continue to be variable which is what I'm trying to fix.

Copy link
Member

Choose a reason for hiding this comment

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

Ah , sorry it was obviously to late yesterday. The current timestamp is already used if the parameter is omitted and I thought it is something similar to the already merged #1541.

So let's change my question :) Why do you want the file to be deterministic?

Copy link
Author

Choose a reason for hiding this comment

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

I subscribe to the idea that the releases that you publish should be built in such a way that other people can repeat the build process and produce the exact same files, down to the bit. This makes it much easier to audit the published binaries/archives. https://reproducible-builds.org/ basically explains why.

There's also a bunch of things already in poetry which make the build results more reproducible, so reproducibility is clearly something that is intended in this project.

@sdispater
Copy link
Member

Thanks for your contribution!

This looks reasonable to me. Could you rebase your changes onto master?

@achow101
Copy link
Author

Rebased

@abn
Copy link
Member

abn commented Oct 24, 2020

Apoligies for dropping the ball on this one. Feel free to ping on discord if something falls through the crack again. We appricate your contributions, issues reports, PRs and doc fixes alike.

@achow101 this needs to move poetry-core now.

@abn
Copy link
Member

abn commented Oct 24, 2020

@achow101 closing this here as this needs to go to poetry-core now anyway.

@achow101
Copy link
Author

Moved to poetry-core: python-poetry/poetry-core#105

Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants