-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
import pkg_resources
triggers a DeprecationWarning on Python 3.9
#2466
Comments
Cross-posted to pypa/packaging#368 because I'm not sure whether the bug is in packaging or in setuptools. |
The issue seems to be that diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 737f4d5f..6ca1c7b4 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2020,7 +2020,8 @@ def _by_version_descending(names):
Parse each component of the filename
"""
name, ext = os.path.splitext(name)
- parts = itertools.chain(name.split('-'), [ext])
+ parts = list(itertools.chain(name.split('-'), [ext]))
+ print(parts)
return [packaging.version.parse(part) for part in parts]
return sorted(names, key=_by_version, reverse=True) I got
With that observation, I created a fix(?) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 737f4d5f..84df31dd 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2020,8 +2020,15 @@ def _by_version_descending(names):
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]
+ parts = list(itertools.chain(name.split('-'), [ext]))
+
+ def parse_version_ignore_invalid(version):
+ try:
+ return packaging.version.Version(version)
+ except packaging.version.InvalidVersion:
+ return version
+
+ return [parse_version_ignore_invalid(part) for part in parts]
return sorted(names, key=_by_version, reverse=True)
UPDATE: I believe the issue also appears on older Python version if packaging is updated to 20.5 or newer [1]. Here is my testing environment:
|
See pypa/setuptools#2466 (cherry picked from commit 822bfec)
….5 (pypa/setuptools#2466) git-svn-id: file:///srv/repos/svn-packages/svn@403088 eb2447ed-0c53-47e4-bac8-5bc4a241df78
….5 (pypa/setuptools#2466) git-svn-id: file:///srv/repos/svn-packages/svn@403088 eb2447ed-0c53-47e4-bac8-5bc4a241df78
Disable three tests until setuptools works with packaging >= 20.5. The tests fail with: > DeprecationWarning: Creating a LegacyVersion has been deprecated > and will be removed in the next major release Upstream issue: pypa/setuptools#2466 git-svn-id: file:///srv/repos/svn-community/svn@840859 9fca08f4-af9d-4005-b8df-a31f2cc04f65
Disable three tests until setuptools works with packaging >= 20.5. The tests fail with: > DeprecationWarning: Creating a LegacyVersion has been deprecated > and will be removed in the next major release Upstream issue: pypa/setuptools#2466 git-svn-id: file:///srv/repos/svn-community/svn@840859 9fca08f4-af9d-4005-b8df-a31f2cc04f65
This is also hit in dask/fastparquet#558. @yan12125's investigation makes it clear: passing an invalid version (the first parts of the name here) throws the DeprecationWarning of setuptools/pkg_resources/__init__.py Lines 2025 to 2027 in c121d28
setuptools/setuptools/_vendor/packaging/version.py Lines 48 to 58 in c121d28
|
I'm closing this in favor #2497. |
I'm pretty sure this is a bug because I don't think pkg_resources is deprecated in its entirety.
The text was updated successfully, but these errors were encountered: