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

bpo-29708: allow to force hash-based pycs #5200

Merged
merged 4 commits into from Jan 24, 2018

Conversation

bmwiedemann
Copy link
Contributor

@bmwiedemann bmwiedemann commented Jan 16, 2018

allow to force hash-based pycs
using the well-established SOURCE_DATE_EPOCH environment variable
to allow for reproducible builds of python packages.

See https://reproducible-builds.org/ for why this is good.

This implements variant 1 from @brettcannon

note: not tested yet

https://bugs.python.org/issue29708

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

Just a request to expand the documentation and tweak the test to follow what is already there for hash-based .pyc files.

@@ -71,6 +71,8 @@ byte-code cache files in the directory containing the source code.

.. versionchanged:: 3.7
The *invalidation_mode* parameter was added as specified in :pep:`552`.
If the :envvar:`SOURCE_DATE_EPOCH` environment variable is set, this will
be forced to CHECKED_HASH.
Copy link
Member

Choose a reason for hiding this comment

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

This should also be mentioned in the main documentation. In other words, if the "version changed" note went away the docs should still cover what they need to cover. So this should say something like "Detecting the :envvar:SOURCE_DATE_EPOCH environment variable to force CHECKED_HASH was added."

py_compile.compile(self.source_path, self.pyc_path)
self.assertTrue(os.path.exists(self.pyc_path))
self.assertFalse(os.path.exists(self.cache_path))
with open(self.pyc_path, "rb") as f:
Copy link
Member

Choose a reason for hiding this comment

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

I would look at

def test_invalidation_mode(self):
as an example on how to make this test a little bit more robust in the face of .pyc files changing.

@bedevere-bot
Copy link

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.

@bmwiedemann
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

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

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

Just waiting until Friday to merge to give people enough time to comment on the proposed solution. Otherwise the PR LGTM!

using the well-established SOURCE_DATE_EPOCH environment variable
to allow for reproducible builds of python packages.

See https://reproducible-builds.org/ for why this is good.
@brettcannon brettcannon merged commit ccbe581 into python:master Jan 24, 2018
@brettcannon
Copy link
Member

Thanks for your patience with this issue, @bmwiedemann !

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.

None yet

4 participants