Fix miniconda version handling

Anaconda and miniconda have changed their version string format again,
so the parsing needs to be done differently. `add_miniconda.py` can now
parse all existing definition files properly.
This commit is contained in:
Alex Hedges 2023-06-23 20:10:18 -04:00
parent 2506c9773c
commit dd5378941a

View file

@ -150,20 +150,23 @@ class CondaVersion(NamedTuple):
"""
Convert a string of the form "miniconda_n-ver" or "miniconda_n-py_ver-ver" to a :class:`CondaVersion` object.
"""
components = s.split("-")
if len(components) == 3:
miniconda_n, py_ver, ver = components
py_ver = PyVersion(f"py{py_ver.replace('.', '')}")
else:
miniconda_n, ver = components
py_ver = None
miniconda_n, _, remainder = s.partition("-")
suffix = miniconda_n[-1]
if suffix in string.digits:
flavor = miniconda_n[:-1]
else:
flavor = miniconda_n
suffix = ""
components = remainder.split("-")
if flavor == Flavor.MINICONDA and len(components) >= 2:
py_ver, *ver_parts = components
py_ver = PyVersion(f"py{py_ver.replace('.', '')}")
ver = "-".join(ver_parts)
else:
ver = "-".join(components)
py_ver = None
return CondaVersion(Flavor(flavor), Suffix(suffix), VersionStr(ver), py_ver)
def to_filename(self):