-
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
pip 21.0.1 fails when run with warnings converted to errors #9540
Comments
This causes the CPython test suite to fail (at least prior to 3.10, I'm not entirely sure why the tests don't fail in cpython master, but ensurepip changed in that version). This is blocking the backport upgrading ensurepip to 21.0.1 in CPython 3.8 and 3.9 🙁 Not upgrading ensurepip isn't a showstopper, though. I'm fine with leaving this fix for 21.1. Possible fixes - remove the pin on setuptools in our vendoring (does this have any risk, or was it just pinned for Python 2 support?) or get on with removing our dependency on pkg_resources. |
... or a 3rd option, we could just override the Python warning settings in |
What is causing the warning in the first place? Presumably there is something in the environment that uses non-PEP-440 versions? If that's the case, it would again be a problem when |
I haven't had the time to dig that deeply. Note that the invalid "version" is "pip", which suggests that something parsed the wrong part of a filename, or something like that. As it doesn't happen when importing pkg_resources from the latest setuptools, I'm inclined to suspect a setuptools bug that has since been fixed. |
I took a look at setuptools, it seems that significant has changed between the versions on this code path. setuptools does not emit a warning simply because it vendors packaging 20.4, before the deprecation warning was introduced 😞 So I guess the most reasonable approach is to either silence the warning (probably by patching |
It was pinned for Python 2, although setuptools has moved forward a lot and we'd likely want to update what all we trim from their source code in the vendoring configuration. |
Upgrading the vendored setuptools will not resolve the issue. The difference between pip and setuptools is setuptools vendors a version of packaging that does not deprecate LegacyVersion. |
Ah. I hadn't spotted that. |
OK, I had some time to debug. Setuptools is the issue, in TBH, I'm not even sure how the code achieves what the docstring says it does. I think it's relying on the fact that def _by_version(name):
"""
Parse each component of the filename
"""
name, ext = os.path.splitext(name)
parts = itertools.chain(name.split('-'), [ext])
return [packaging.version.parse(part) for part in parts] The following fixes it: def _by_version(name):
"""
Parse each component of the filename
"""
name, ext = os.path.splitext(name)
parts = itertools.chain(name.split('-'), [ext])
def safe_parse(s):
try:
return packaging.version.parse(s)
except (packaging.version.InvalidVersion, DeprecationWarning):
return s
return [safe_parse(part) for part in parts] but I don't like (1) that it's not obvious to me that it does the same as the original in edge cases, and (2) that we have to catch I've submitted pypa/setuptools#2547 to let them know about the issue, but it's not likely to hit them soon, so I think we need a local solution for now. |
I think our local solution should be to switch to importlib.metadata. 🙃 |
Agreed, but is anyone actively working on that? A short term fix (which I just tested, briefly) is to add
to It might also be worth our while adding a test to the test suite, just to check that |
As I say, though, I don't think this is a big enough deal to do a bugfix release, so there's no rush to fix it before 21.1. I'm fine with 21.0.1 not being backported into 3.8 and 3.9. It's worth noting, though, that there are scheduled Python 3.8 and 3.9 releases on 2021-04-19, with the RC on 2021-04-05, so getting pip 21.1 into those will be a bit tight. And that 3.8 release is the final bugfix release, so if we miss that, 3.8 will never get a newer version of pip than 20.2.3. I'm going to count that as a problem for the 21.1 RM, though 🙂 |
Things are blocked by #8114, I’m waiting for a good timing to merge it. But even after merging the PR, the transition likely won’t finish for 21.1 (unless significant resources being suddenly made available), so better not count on that being the solution. |
Related #9250 |
Environment
Description
With the latest version of packaging (vendored in 21.0.1) a DeprecationWarning is issued when parsing a "legacy version". If pip is run with warnings converted to errors, this causes a failure.
Expected behavior
No error
How to Reproduce
py -wE -m pip --version
Or to pinpoint it further,
This does not happen with setuptools 52.0.0, it appears to be related to the version of setuptools (44.0.0) that we vendor.
Output
The text was updated successfully, but these errors were encountered: