question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should 'pip cache purge' remove more than wheel files?

See original GitHub issue

What’s the problem this feature will solve?

https://github.com/pypa/pip/issues/4685 says:

pip’s cache is currently a black box that the users can’t really inspect. This is not the nicest of experiences. Adding a pip cache to allow interacting with the cache (much like the new pip config) would be a good way to fix that.

Currently git cache purge in #6391 only removes the *.whl files from the pip/wheels/ directory.

This leaves:

  • a lot of empty directories under pip/wheels/ (eg. 1,608 dirs, 57 KB)
  • a lot of files under pip/http/ (eg. 2,408 files, 6,850 dirs, 2.1 GB)
  • a selfcheck.json and pip/selfcheck/ directory (eg. 45 files, 27 KB)

Should they also be cleaned up?

pip cache --help says `purge will “Remove all items from the cache”, but it doesn’t.

Split out from https://github.com/pypa/pip/pull/6391#issuecomment-554368620 for follow-up after #6391 is merged.

Describe the solution you’d like

  1. Should pip cache purge remove the pip/wheels/ directory itself so all the subdirs are also cleaned up? In my case, it’s only 57 KB afterwards, but I guess I don’t need those at all, and there’s potential for them to slow down the computer.

  2. And I also still have a 2.1 GB pip/http/ directory after purge. Should that also be removed?

  3. And selfcheck.json and pip/selfcheck/ are only 27 KB, but should purge remove the whole pip/ cache dir?

~I think my pip/wheels/ directory was quite small, especially when compared with pip/wheels/.~ [typo, cannot remember original]

Alternative Solutions

  • Leave the files and directories as is, to accumulate.

  • Feature request https://github.com/pypa/pip/issues/7350 would allow the user to find out where the cache directory is, and writing their own commands to delete files and directories. It’d be nicer for this to be built into pip cache purge.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
duckinatorcommented, Oct 26, 2020

I’m working on a PR for this. To start, I’m focusing on three things:

  1. Having pip cache purge just remove everything under the http and wheel directories.
  2. Having pip cache remove prune empty directories.
  3. Removing selfcheck.json if it exists.

The pip/selfcheck/ directory requires more logic, and I may wind up leaving it for a follow-up PR.

1reaction
pradyunsgcommented, Oct 18, 2020

And my local selfcheck.json was last updated on 2 August, so looks unused.

It’s used as part of the “hey, upgrade your pip” messaging – we shouldn’t remove this.

All OK to delete the empty directories. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip uses incorrect cached package version, instead of the user ...
With pip 20.1 or later, you can do: pip cache remove matplotlib : removes all wheel files related to matplotlib from pip's cache....
Read more >
Trimming pip cache? (distinct from purging) - Packaging
I'm running low on space so want to get rid of unnecessary files. I know that I can completely clean out the pip...
Read more >
Changelog - pip documentation v21.1.dev0
Remove support for legacy wheel cache entries that were created with pip versions ... This should provide more tags ordered better than in...
Read more >
Removing pip's cache? - JanBask Training
If you want to force pip to clear out its download cache and use the specific version you can do by using --no-cache-dir...
Read more >
Pip Clear Cache - Linux Hint
It offers a command-line utility that allows you to manage Python packages easily. Using pip, you can perform actions such as downloading, installing,...
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