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

Add 'pip cache dir' command to show cache directory #8095

Merged
merged 2 commits into from
Apr 27, 2020

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Apr 20, 2020

Fixes #7350.

Print out the path to pip's cache directory, which is different depending on OS.

For example on macOS:

$ pip cache dir
/Users/hugo/Library/Caches/pip
$ pip cache dir 123
ERROR: Too many arguments

This will allow CIs like GitHub Actions to cache pip downloads with much less config, hopefully increasing use of caching, and should reduce the load and cost of running PyPI.

Others would benefit from this, and some have been resorting to using pip's private, internal API:

@duckinator
Copy link
Contributor

duckinator commented Apr 20, 2020

I think a lot of folks will benefit from having a way to easily determine the cache directory, especially in CI environments. 🙂

@pradyunsg pradyunsg added C: cache Dealing with cache and files in it type: enhancement Improvements to functionality labels Apr 27, 2020
@pradyunsg pradyunsg added this to the 20.1 milestone Apr 27, 2020
def get_cache_dir(self, options, args):
# type: (Values, List[Any]) -> None
if args:
raise CommandError('Too many arguments')
Copy link
Member

Choose a reason for hiding this comment

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

A test hitting this branch would be great! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Test added in 6b640d1

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

LGTM, other than a non-blocking comment for an additional test.

@pradyunsg
Copy link
Member

puts on release manager hat

This looks like a useful change, enhancing a feature we've got in the beta. OK to put this into the 20.1 release.

@pradyunsg pradyunsg merged commit 22bd8ad into pypa:master Apr 27, 2020
@hugovk hugovk deleted the pip-cache-dir2 branch April 29, 2020 14:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: cache Dealing with cache and files in it type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cross-platform command to return pip's cache directory
4 participants