You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically, pip vendors pkg_resources, but uses it with pip's own vendored copy of packaging, not with the one setuptools vendors. In the latest release of packaging, legacy versions are deprecated and trigger a DeprecationWarning. Python's test suite runs pip with warnings converted to errors, and this resulted in a failure, which I traced back to the following code in pkg_resources:
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) forpartinparts]
(This is an internal function of _by_version_descending). The code is the same in the latest version of setuptools.
Note that this code parses every part of the filename, not checking whether the parse works and so relying on the fact that packaging will currently parse any old garbage, returning a LegacyVersion. This is what triggers the issue here.
Obviously, setuptools won't hit an issue here until it upgrades its vendored copy of packaging to one that finally removes LegacyVersion (or one that deprecates, if the user is running with warnings treated as errors). So it's not an immediate issue here (even though it is for pip).
The following code fixes this problem, but it's not exactly attractive, and I'm not sure whether there's any implication to sometimes returning a string and sometimes a Version. Also, I haven't checked anywhere else to see if this same pattern is repeated anywhere else in setuptools. Maybe it's useful, nevertheless.
def_by_version(name):
""" Parse each component of the filename """name, ext=os.path.splitext(name)
parts=itertools.chain(name.split('-'), [ext])
defsafe_parse(s):
try:
returnpackaging.version.parse(s)
except (packaging.version.InvalidVersion, DeprecationWarning):
returnsreturn [safe_parse(part) forpartinparts]
The text was updated successfully, but these errors were encountered:
See pypa/pip#9540 for background here.
Basically, pip vendors
pkg_resources
, but uses it with pip's own vendored copy ofpackaging
, not with the one setuptools vendors. In the latest release ofpackaging
, legacy versions are deprecated and trigger aDeprecationWarning
. Python's test suite runs pip with warnings converted to errors, and this resulted in a failure, which I traced back to the following code inpkg_resources
:(This is an internal function of
_by_version_descending
). The code is the same in the latest version of setuptools.Note that this code parses every part of the filename, not checking whether the parse works and so relying on the fact that packaging will currently parse any old garbage, returning a
LegacyVersion
. This is what triggers the issue here.Obviously, setuptools won't hit an issue here until it upgrades its vendored copy of
packaging
to one that finally removesLegacyVersion
(or one that deprecates, if the user is running with warnings treated as errors). So it's not an immediate issue here (even though it is for pip).The following code fixes this problem, but it's not exactly attractive, and I'm not sure whether there's any implication to sometimes returning a string and sometimes a
Version
. Also, I haven't checked anywhere else to see if this same pattern is repeated anywhere else in setuptools. Maybe it's useful, nevertheless.The text was updated successfully, but these errors were encountered: