Improve metadata validation and handling of invalid distributions - #14219
Improve metadata validation and handling of invalid distributions#14219sepehr-rs wants to merge 16 commits into
Conversation
|
CI is currently failing in two cases, and I wanted to check on the intended behavior before fixing them.
The second one feels like the bigger design question. Pip has tolerated legacy version strings till now, so skipping these distributions in Happy to implement either approach. |
2ykwang
left a comment
There was a problem hiding this comment.
might be moot depending on the design outcome, but left a small test nit I noticed while reading.
|
To answer your design questions:
We should maintain the old behaviour here. The goal here to become stricter over time.
Legacy versions are still part of the packaging standards and are perfectly legal when using the Also, have you checked the performance implications of this metadata validation layer? I left some comments on performance in the linked issue: #13638 (comment) |
|
Thanks a lot for the review @ichard26!
Oh, thanks for flagging this. I benchmarked four commands ( The listing commands show no meaningful overhead; the slope difference is ≤0.03 ms/package and within noise throughout. I've attached a plot showing the scaling behaviour:
Also, keep in mind that benchmark script only creates valid packages, not invalid ones. Since the code returns early on the first validation failure, corrupt packages are cheaper to validate than valid ones; so real-world overhead on Here's the benchmark script that I created with the help of Claude in case you want to run it yourself. |

What does this PR do?
This PR addresses #13638 by introducing a centralized metadata validation layer for installed distributions. Invalid distributions are now detected consistently, with clearer warning messages explaining the underlying issue, while commands such as
showanduninstallcontinue to operate on invalid installations where possible to help users recover from broken distributions.I'm happy to hear any feedback on the overall approach or implementation.
PR Checklist:
Assisted-by: Claude (code review)