-
Notifications
You must be signed in to change notification settings - Fork 62
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
More respectful convention for caching #814
More respectful convention for caching #814
Conversation
On Windows, although not "officially" a convention, it appears that programs like `pip` use %LocalAppData%\<program_name>\Cache. This commit implements that default. See https://pip.pypa.io/en/latest/topics/caching/#default-paths. Closes pypa#342.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aanghelidi, this looks pretty reasonable to me. pip-audit
's choice of cache location isn't a stability commitment we make, so we should be fine to change this without making a major release.
A couple of thoughts:
- Maybe we could use
platformdirs
to abstract the cache location discovery for us? OTOH the current logic in_get_internal_cache_path
is pretty simple; curious what you think. - Maybe we should blow away the old cache if a new path is discovered? Otherwise, users will end up silently keeping
_PIP_AUDIT_INTERNAL_CACHE
around in their$HOME
taking up space, which isn't very polite of us.
For the second point, something like this is what I have in mind:
# if the selected internal cache isn't the old one, delete the old one.
if internal_cache_path != _PIP_AUDIT_LEGACY_INTERNAL_CACHE:
shutil.rmtree(_PIP_AUDIT_LEGACY_INTERNAL_CACHE)
CC @di for thoughts as well 🙂
Thanks @woodruffw for the review 🙂 TIL about platformdirs ! This is indeed a really handy package. Regarding the aforementioned points:
I added a commit using |
I think we should just blow it away for now -- #794 covers some larger architectural changes we need to make to handle newer versions of
LGTM, thank you! |
Thank you for the context @woodruffw ! I added a extra commit to delete the old cache that goes into that direction. Let me know what you think 🙂 |
b00c525
to
f67e9cc
Compare
pip_audit/_cache.py
Outdated
def _delete_legacy_cache_dir(current_cache_dir: Path, legacy_cache_dir: Path) -> None: | ||
""" | ||
Deletes the legacy `pip-audit` if it exists. | ||
""" | ||
if current_cache_dir != legacy_cache_dir: | ||
shutil.rmtree(legacy_cache_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a helper here; let's just inline this into _get_cache_dir
IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last commit now inline the deletion into _get_cache_dir
✔️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aanghelidi, LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one last request: could you add a CHANGELOG
entry for this change? See the other entries in the log for our preferred style.
Signed-off-by: William Woodruff <[email protected]>
A PR that aims to close #342.
All the logic is inside
_get_internal_cache_path
in_cache.py
.