From 2a63f4fbf92a38c750b9a8355bff202508cf64fe Mon Sep 17 00:00:00 2001 From: Yamato Matsuoka Date: Fri, 2 Sep 2022 21:24:40 -0400 Subject: [PATCH 1/2] Support ~= as version specifier --- condax/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/condax/utils.py b/condax/utils.py index de285de..f7ac35e 100644 --- a/condax/utils.py +++ b/condax/utils.py @@ -8,7 +8,7 @@ from condax.exceptions import CondaxError -pat = re.compile(r"<=|>=|==|!=|<|>|=") +pat = re.compile(r"(?=~=|<=|>=|==|!=|<|>|=|$)") def split_match_specs(package_with_specs: str) -> Tuple[str, str]: From 175c9186806324827b81eb53f4974dc8a0fcf5c3 Mon Sep 17 00:00:00 2001 From: Yamato Matsuoka Date: Fri, 2 Sep 2022 21:26:31 -0400 Subject: [PATCH 2/2] Fix doctest s.t `pytest --doctest-modules` work + Clean up --- condax/utils.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/condax/utils.py b/condax/utils.py index f7ac35e..afcac33 100644 --- a/condax/utils.py +++ b/condax/utils.py @@ -19,26 +19,24 @@ def split_match_specs(package_with_specs: str) -> Tuple[str, str]: Assume the argument `package_with_specs` is unquoted. >>> split_match_specs("numpy=1.11") - ("numpy", "=1.11") + ('numpy', '=1.11') >>> split_match_specs("numpy==1.11") - ("numpy", "==1.11") + ('numpy', '==1.11') >>> split_match_specs("numpy>1.11") - ("numpy", ">1.11") + ('numpy', '>1.11') >>> split_match_specs("numpy=1.11.1|1.11.3") - ("numpy", "=1.11.1|1.11.3") + ('numpy', '=1.11.1|1.11.3') >>> split_match_specs("numpy>=1.8,<2") - ("numpy", ">=1.8,<2") + ('numpy', '>=1.8,<2') >>> split_match_specs("numpy") - ("numpy", "") + ('numpy', '') """ - name, *_ = pat.split(package_with_specs) - # replace with str.removeprefix() once Python>=3.9 is assured - match_specs = package_with_specs[len(name) :] + name, match_specs = pat.split(package_with_specs, 1) return name.strip(), match_specs.strip()