pip freeze with a hash

See original GitHub issue
  • Pip version: 9.0.1
  • Python version: 3.5.4
  • Operating system: Debian / PureOS

Description:

User story: I am a Python developer with an existing requirements.txt file. I want to add hashes to the file, so that future installations are more secure.

What I’ve run:

At the moment I need to:

  • Locate the package.tar.gz or package.whl
  • Run pip hash /path/to/package
  • Copy the result into requirements.txt
  • Repeat for every package

It would be great if instead I could:

  • Run pip freeze --hash
  • Get pip-formatted output with all package names and their hashes
  • Copy the result into requirements.txt

Today’s solution:

Pipfile is a replacement for requirements.txt that includes hashes in a file called Pipfile.lock.

pipenv is a tool for managing your virtualenv based on Pipfile, including checks against the hashes defined in Pipfile.lock. (It can also convert a requirements.txt file.)

Suggested solution:

Supporting Pipfile at the pip layer (rather than a higher-level tool) is on the PyPA roadmap, see https://github.com/pypa/pipfile#pip-integration-eventual :

pip will grow a new command line option, -p / --pipfile to install the versions as specified in a Pipfile, similar to its existing -r / --requirement argument for installing requirements.txt files. … To manually update the Pipfile.lock:

$ pip freeze -p different_pipfile different_pipfile.lock (73d81f) written to disk.

The implication is that this is the preferred solution to supporting hashes (rather than adding them to requirements.txt or pip freeze). The current status “Deferred till PR” (see this ticket). See also https://github.com/pypa/pip/issues/6925

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:47
  • Comments:48 (22 by maintainers)

github_iconTop GitHub Comments

10reactions
Juliancommented, Aug 4, 2018

@andrewchambers perhaps instead of the slight barbs consider sending a PR?

9reactions
Juliancommented, Aug 6, 2018

Are you saying you think the entirety of pip freeze is out of scope for pip now?

Because if not, this seems like a very logical thing for pip. Not all of us use any current higher level tool, and it’s pip itself that introduced the possibility of having hashes in requirements files.

Without this feature it’s pretty unfeasible to generate those.

Saying “patches welcome” seems very reasonable, but closing not so much.

On Mon, Aug 6, 2018, 17:26 d❤vid notifications@github.com wrote:

Closed #4732 https://github.com/pypa/pip/issues/4732.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pypa/pip/issues/4732#event-1773030507, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUIXkYXs7_gKTjNsPIAurvfoyr6k-Gkks5uOFIagaJpZM4Pduuk .

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip hash - pip documentation v22.3.1
pip hash is a convenient way to get a hash digest for use with Hash-checking Mode, especially for packages with multiple archives. The...
Read more >
Generating a Fully-Qualified and Hashed Python ...
A discussion and script showing how to generate a fully-qualified and hashed requirements file using python.
Read more >
Add an entry to requirements.txt that has hash values in it
Add an entry to requirements.txt that has hash values in it ... first python -m pip install 'pandas==1.0.4' and then python -m pip...
Read more >
Bestest and securest way to handle Python dependencies
The tricks is to install hashin . ( pip install hashin ). It helps you write those hashes. Suppose you have a requirements.txt...
Read more >
Get Python Requirements Package Hashes - David Walsh Blog
pip -compile (from pip-tools ) can generate hashes in a requirements file, using the option --generate-hashes .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found