-
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 CLI emits DeprecationWarning due to use of LegacyVersion #9250
Comments
I can reproduce: Long traceback (click to expand)$ python3 -Werror -m pip
Traceback (most recent call last):
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/packaging/version.py", line 57, in parse
return Version(version)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/packaging/version.py", line 298, in __init__
raise InvalidVersion("Invalid version: '{0}'".format(version))
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'setuptools'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/__main__.py", line 23, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
from pip._internal.utils.logging import get_indentation
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
from pip._internal.utils.misc import ensure_dir
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 21, in <module>
from pip._vendor import pkg_resources
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3252, in <module>
def _initialize_master_working_set():
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3235, in _call_aside
f(*args, **kwargs)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 574, in _build_master
ws = cls()
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 567, in __init__
self.add_entry(entry)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 623, in add_entry
for dist in find_distributions(entry, True):
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2061, in find_on_path
path_item_entries = _by_version_descending(filtered)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2034, in _by_version_descending
return sorted(names, key=_by_version, reverse=True)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2032, in _by_version
return [packaging.version.parse(part) for part in parts]
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2032, in <listcomp>
return [packaging.version.parse(part) for part in parts]
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/packaging/version.py", line 59, in parse
return LegacyVersion(version)
File "/tmp/pip_test/venv/lib/python3.8/site-packages/pip/_vendor/packaging/version.py", line 127, in __init__
warnings.warn(
DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release All that's installed is:
I can narrow it down to: pip/src/pip/_vendor/pkg_resources/__init__.py Line 2032 in 27d8687
where the value of |
The same bug has been reported over at pypa/setuptools#2466 and pypa/packaging#368, and there's a draft fix: pypa/setuptools#2478 |
I think this has been fixed in pypa/setuptools@47b9bf5 . So updating the vendored |
Neat. We can finally get rid of the noise here and make this a proper warning. |
FWIW, the plan is for this warning to preceed the removal of handling of non-PEP 440 versions. |
Oh finally! (I’m happy but also a bit sad seeing this needing a contribution from Jason.) |
I still get this warning with |
In my return [packaging.version.parse(part) for part in parts] I'm not sure how the vendoring process in pip works. Is there any action required besides installing a current pip version, or do we have to wait until a maintainer updates the dependency in |
IIRC recent setuptools versions change too significantly for pip to reasonably vendor, so someone will need to manually cherry-pick the change in. Feel free. (Or just use 3.11+ or later where the metadata backend has been switched to importlib.metadata.) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I have a virtualenv where I get the same. The ['pip-23.0.1.dist-info', 'setuptools-65.5.0.dist-info'] Which fails because of this: parts = itertools.chain(name.split('-'), [ext])
return [packaging.version.parse(part) for part in parts] So it tries to parse the version |
Consolidating into #11715. |
Environment
Description
pip
CLI consistently causes a DeprecationWarning to be emitted from its own vendoredpackaging
. This is not observed in pip 20.2.3Expected behavior
Expect no DeprecationWarning
How to Reproduce
Output
To create an environment with an older version of
pip
:With
PYTHONWARNINGS
environment variable set to"default"
, no DeprecationWarnings:Then upgrade to 20.3.1:
DeprecationWarning appears.
The text was updated successfully, but these errors were encountered: