From dd5378941ac4700ab54ceacb7dbe498546d88e26 Mon Sep 17 00:00:00 2001 From: Alex Hedges Date: Fri, 23 Jun 2023 20:10:18 -0400 Subject: [PATCH] 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. --- plugins/python-build/scripts/add_miniconda.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/python-build/scripts/add_miniconda.py b/plugins/python-build/scripts/add_miniconda.py index 0dfd2ce1..f5981d23 100755 --- a/plugins/python-build/scripts/add_miniconda.py +++ b/plugins/python-build/scripts/add_miniconda.py @@ -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):