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

Expose pip's cache dir #107

Open
woodruffw opened this issue Oct 27, 2021 · 5 comments
Open

Expose pip's cache dir #107

woodruffw opened this issue Oct 27, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@woodruffw
Copy link
Collaborator

pypa/pip-audit#75 tries to re-use the pip cache whenever possible.

The pip cache's location is normally system defined (but consistent), but it can probably be overridden.

Proposed API: pip_api.cache_dir() -> Path, corresponding to the pip cache dir command.

@di
Copy link
Owner

di commented Oct 27, 2021

A reminder that the goal of this library is to providing a drop-in replacement for existing uses of pip's internal API by wrapping command-line calls to pip, so any new API added here needs to have the equivalent:

  1. accessible from some internal pip API (or combination of internal APIs)
  2. accessible from some command-line calls (or combination of command-line calls)

This one's somewhat complicated: if I wanted to get the cache dir from pip's internal API, I'd need to do something like:

>>> from pip._internal.cli.base_command import Command
>>> c = Command('throwaway', 'throwaway')
>>> options, args = c.parse_args([])
>>> options.cache_dir
'/root/.cache/pip'

So it seems like an API to get all the options available would be preferable, but there's no CLI to get this value as far as I can tell.

We might want to think about a more general API that provides various default configuration values like cache_dir, and combines multiple CLI commands like pip cache dir instead.

@woodruffw
Copy link
Collaborator Author

woodruffw commented Oct 27, 2021

So it seems like an API to get all the options available would be preferable, but there's no CLI to get this value as far as I can tell.

Does pip cache dir not work for you? It does for me, on macOS:

work:~ william$ pip cache dir
/Users/william/Library/Caches/pip

Edit: It looks like pip cache dir was added in 20.1, so that explains why it might be absent by default with a distro-provided pip.

@di
Copy link
Owner

di commented Oct 27, 2021

So it seems like an API to get all the options available would be preferable, but there's no CLI to get this value as far as I can tell.

Emphasis on "all the options", I think an API to just get the cache directory is probably too fine-grained here given how many options there are.

@woodruffw
Copy link
Collaborator Author

woodruffw commented Oct 27, 2021

Emphasis on "all the options", I think an API to just get the cache directory is probably too fine-grained here given how many options there are.

Gotcha, I understand now! Yeah, there's nothing that does all config options via the pip CLI that I'm aware of.

@woodruffw
Copy link
Collaborator Author

(There's pip config list, but AFAICT it doesn't dump any default settings that aren't explicitly overridden.)

@di di added the enhancement New feature or request label Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants