Closed jwodder closed 1 year ago
Also true of distutils.version.LooseVersion
:
In [1]: from distutils.version import LooseVersion
In [2]: versions = ['0.3.1@v0.3.1', '0.3@v0.3', '0.2.2.2@v0.2.2.2', '0.2.2.1@v0.2.2.1', '0.2.2@v0.2.
...: 2', '0.2.1.1-2@v0.2.1.1-2', '0.2.1.1-1@v0.2.1.1-1', '0.2-1@v0.2-1']
In [3]: versions.sort(key=LooseVersion)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 versions.sort(key=LooseVersion)
File ~/miniconda3/lib/python3.8/site-packages/setuptools/_distutils/version.py:72, in Version.__lt__(self, other)
71 def __lt__(self, other):
---> 72 c = self._cmp(other)
73 if c is NotImplemented:
74 return c
File ~/miniconda3/lib/python3.8/site-packages/setuptools/_distutils/version.py:352, in LooseVersion._cmp(self, other)
350 if self.version == other.version:
351 return 0
--> 352 if self.version < other.version:
353 return -1
354 if self.version > other.version:
TypeError: '<' not supported between instances of 'str' and 'int'
Here's what's happening:
In [16]: LooseVersion(versions[0]).version
Out[16]: [0, 3, 1, '@', 'v', 0, 3, 1]
In [17]: LooseVersion(versions[1]).version
Out[17]: [0, 3, '@', 'v', 0, 3]
I'm assuming you don't want to strip the @*
, but this does seem like a use-case LooseVersion was not designed for, and these versions are redundant.
If there's something actionable here, please reopen.
This should be resolved in 1.2.0.
Using looseversion 1.0.1 on Python 3.10.6, the following occurs: