-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix pip cache remove
pattern matching.
#13094
base: main
Are you sure you want to change the base?
Conversation
Previously, glob patterns were not properly accounted for, which could lead to `pip cache remove wheel-0.45.1-py3-none-any.whl` failing, for example, when exactly that file was shown to exist in the cache via `pip cache list`. Additionally, non-glob patterns previously only literally matched wheel project names; now they match the normalized name. For example, `pip cache remove pyfftw` will now remove a cached `pyFFTW-0.15.0-cp313-cp313-linux_x86_64.whl` wheel since the `pyfftw` pattern matches the normalized project name. Fixes pypa#13086
glob_pattern_char in pattern for glob_pattern_char in ("[", "*", "?") | ||
) | ||
if not uses_glob_patterns: | ||
project_name, sep, rest = pattern.partition("-") |
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.
N.B. I documented punting on deciphering glob patterns with respect to name normalization. Someone braver than I might try that later. I assume forward progress here is better than no progress though.
I did not, however, call the shot on version normalization. Again, I was cowardly, but that problem still remains. If a wheel in the cache is foo-1.0-py3-none-any.whl
, then, in my opinion, pip cache remove foo-1.0.0
should remove it, but does not today.
# PEP 427: https://www.python.org/dev/peps/pep-0427/ | ||
pattern = pattern + ("*.whl" if "-" in pattern else "-*.whl") | ||
|
||
return filesystem.find_files(wheel_dir, pattern) | ||
# And: https://packaging.python.org/specifications/binary-distribution-format/ |
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.
For Pip / PyPA knowledgeable reviewers - what the heck is up with this by the way? I've always found it off-putting since the PEP banners have started appearing on some of the PyPA PEPs re-directing to these new standards pages. The fact that some PEPs get a new page and some don't and what process the ones with the new page go through to get updated is all mysterious feeling.
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.
This change makes the implementation more in-line with my intentions back in #6391.
The glob check in particular looks way more robust now. 🙂
Previously, glob patterns were not properly accounted for, which could
lead to
pip cache remove wheel-0.45.1-py3-none-any.whl
failing, forexample, when exactly that file was shown to exist in the cache via
pip cache list
.Additionally, non-glob patterns previously only literally matched wheel
project names; now they match the normalized name. For example,
pip cache remove pyfftw
will now remove a cachedpyFFTW-0.15.0-cp313-cp313-linux_x86_64.whl
wheel since thepyfftw
pattern matches the normalized project name.
Fixes #13086