From ff6cee4a44de3a4240d1019d88d3c9522a234b5b Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 16 Jun 2022 23:22:29 +0300 Subject: [PATCH] Fix requirements --extra-index-url line with trailing comment Fix --extra-index-url is added for different command line switches --- clearml_agent/external/requirements_parser/parser.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clearml_agent/external/requirements_parser/parser.py b/clearml_agent/external/requirements_parser/parser.py index 77f0088..2864040 100644 --- a/clearml_agent/external/requirements_parser/parser.py +++ b/clearml_agent/external/requirements_parser/parser.py @@ -1,4 +1,5 @@ import os +import re import warnings from clearml_agent.definitions import PIP_EXTRA_INDICES @@ -44,10 +45,12 @@ def parse(reqstr, cwd=None): yield requirement elif line.startswith('-f') or line.startswith('--find-links') or \ line.startswith('-i') or line.startswith('--index-url') or \ - line.startswith('--extra-index-url') or \ line.startswith('--no-index'): - _, extra_index = line.split() - if extra_index not in PIP_EXTRA_INDICES: + warnings.warn('Private repos not supported. Skipping.') + elif line.startswith('--extra-index-url'): + extra_index = line[len('--extra-index-url'):].strip() + extra_index = re.sub(r"\s+#.*$", "", extra_index) # strip comments + if extra_index and extra_index not in PIP_EXTRA_INDICES: PIP_EXTRA_INDICES.append(extra_index) print(f"appended {extra_index} to list of extra pip indices") continue