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

Feature request: use --hash to match correct file #6395

Closed
bennuttall opened this issue Apr 9, 2019 · 4 comments
Closed

Feature request: use --hash to match correct file #6395

bennuttall opened this issue Apr 9, 2019 · 4 comments
Labels
auto-locked Outdated issues that have been locked by automation resolution: duplicate Duplicate of an existing issue/PR

Comments

@bennuttall
Copy link

What's the problem this feature will solve?

When a package includes hashes for their dependencies, and the user is using a third-party repo as their additional index, pip may choose to use a file from the additional index rather than PyPI (e.g. if the third party provides a wheel and PyPI doesn't), in which case the hash will not match and the installation will fail. If a matching hash is required, and the file with the required hash is available, this file should take priority even if it is usually of lower presedence to pip (i.e. bdist vs sdist).

Describe the solution you'd like

I suggest that when a hash is specified, pip should only attempt to install a file with a matching hash, even when alternative otherwise suitable files are available.

Scenario:

(using 6-character hashes for brevity)

  • Index: pypi.org
  • Additional index: piwheels.org
  • pypi.org provides package-1.0.0-none-any.whl with hash abcdef
  • piwheels.org provides package-1.0.0.tar.gz with hash beefed

Example (current):

$ pip install package==1.0.0 --hash=sha256:abcdef -v
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting package
  2 location(s) to search for versions of package:
  * https://pypi.org/simple/package/
  * https://www.piwheels.org/simple/package/
...
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    package==1.0.0 from https://www.piwheels.org/simple/package/package-1.0.0-none-any.whl#sha256=abcdef
        Expected sha256 abcdef
             Got        beefed

Example (proposed):

$ pip install package==1.0.0 --hash=sha256:abcdef -v
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting package
  2 location(s) to search for versions of package:
  * https://pypi.org/simple/package/
  * https://www.piwheels.org/simple/package/
...
Downloading https://files.pythonhosted.org/packages/.../package-1.0.0.tar.gz
...
Successfully installed package

Alternative Solutions

Related to #6394 but a different problem.

Additional context

I maintain a third-party repo at piwheels.org for Raspberry Pi users and we pre-configure /etc/pip.conf in Raspbian to set extra-index-url. If users want to make sure their installation comes from PyPI to match the hash, they have to remove /etc/pip.conf. But it's not obvious that's the case.

See piwheels/piwheels#144

@bcutter
Copy link

bcutter commented Apr 10, 2019

This would have solved my issue which I needed to work around manually (quite time consuming) :-(

certbot/certbot#6933 (comment)

@cjerdonek
Copy link
Member

Is this the same issue? #5874

@bennuttall
Copy link
Author

Yes, it seems so. I'll close it and add my support to that one.

@lock
Copy link

lock bot commented May 28, 2019

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

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests

3 participants