Skip to content

Support --hash on the command line #3257

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

Open
erikrose opened this issue Nov 20, 2015 · 4 comments
Open

Support --hash on the command line #3257

erikrose opened this issue Nov 20, 2015 · 4 comments
Labels
type: enhancement Improvements to functionality

Comments

@erikrose
Copy link
Contributor

#3137 supports specifying package hashes using --hash in requirements files. The next step is to support --hash on the command line so, both for consistency and for the convenience of not having to make a temporary requirements file just to install a package while checking against a hash.

A prerequisite to this is probably to change from optparse to click, which supports the interleaving of options and arguments on the command line. @dstufft mentioned an interested in making this switch at one point. The intent is for this to work:

pip install foo==1.0 --hash=sha256:hash_for_foo12345 \
            bar==2.0 --hash=sha256:hash_for_bar12345 --hash=sha256:another_hash_for_bar12345
@xavfernandez xavfernandez added the type: enhancement Improvements to functionality label Nov 23, 2015
@pradyunsg
Copy link
Member

Linking with #4659.

@edmorley
Copy link
Contributor

Is switching from optparse to click still a prerequisite for this?

@pfmoore
Copy link
Member

pfmoore commented Feb 28, 2023

What is necessary is to have an option structure that is supported by our command line parser. The proposed structure needs to interleave non-option arguments and options, which optparse doesn't support. If you want to propose a different UI, which works with optparse, then switching to click might no longer be a prerequisite.

But personally, I can't think of any UI that wouldn't be clumsy here. The UI proposed by the OP here strikes me as being "less bad" rather than actually good. And given that I don't think the arguments for needing this feature are very strong in the first place, I'm not in favour of a bad UI for a not-very-useful feature...

@Ablu
Copy link

Ablu commented Mar 31, 2025

Workaround in some cases can be to use an anonymous pipe to "fake" a requirements.txt:

pip install --require-hashes -r <(echo 'uv==0.6.11 --hash=sha256:6f3c2adb80f0b93ad312daff7ebb1bf4b26456d7d35a1687827ed03f11d238d7')

[tested with bash]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests

6 participants