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

Support wheel cache when using --require-hashes #11042

Closed
wants to merge 1 commit into from

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Apr 18, 2022

This is a very rough sketch, to get an idea of how well this fits in the existing code base and get initial feedback.

This works by recording a origin.json in the wheel cache directory entries (in PEP 610 format).

I'll annotate the diff with the parts that need refactoring IMO. @pypa/pip-committers feel free to suggest others.

closes #5037

@sbidoul sbidoul marked this pull request as draft April 18, 2022 15:20
@sbidoul sbidoul force-pushed the wheel-cache-origin-json branch from 998eef7 to ce5e145 Compare April 18, 2022 15:21
@@ -128,6 +142,7 @@ def unpack_url(
verbosity: int,
download_dir: Optional[str] = None,
hashes: Optional[Hashes] = None,
archive_hash: Optional[str] = None,
Copy link
Member Author

@sbidoul sbidoul Apr 18, 2022

Choose a reason for hiding this comment

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

Passing this archive_hash to unpack_url and then to get_file_url is the ugly part.
I think we could clean this up by avoiding calling unpack_url when the url points to a wheel in the wheel cache (as it does not unpack anyway).

If people are ok with general approach I'll investigate that next.

Copy link
Member

Choose a reason for hiding this comment

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

Passing archive_hash around like this feels wrong, especially get_file_url (if it’s passed, a bulk of the logic in the function isn’t used at all). This should be refactored a bit.

@sbidoul
Copy link
Member Author

sbidoul commented Apr 18, 2022

To illustrate, pip install "wrapt<1.13" will add this origin.json to the wheel cache directory entry:

{
  "archive_info": {
    "hash": "sha256=b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
  }, 
  "url": "https://files.pythonhosted.org/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz"
}

@pradyunsg
Copy link
Member

Going to go ahead and close this, since it has merge conflicts that haven't been resolved in a while. Please feel welcome to file a new PR or to reopen and update this one!

@pradyunsg pradyunsg closed this Sep 30, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs rebase or merge PR has conflicts with current master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support wheel cache when using --require-hashes
3 participants