Allow parsing of "package @ scheme://link" lines in requirements

This commit is contained in:
allegroai 2020-10-04 19:34:32 +03:00
parent c7a739fafa
commit ca0870b048

View File

@ -216,20 +216,25 @@ class Requirement(object):
# or a VCS project URI # or a VCS project URI
return cls.parse_editable( return cls.parse_editable(
re.sub(r'^(-e|--editable=?)\s*', '', line)) re.sub(r'^(-e|--editable=?)\s*', '', line))
elif '@' in line: elif '@' in line and ('#' not in line or line.index('#') > line.index('@')):
# Allegro bug fix: support 'name @ git+' entries # Allegro bug fix: support 'name @ git+' entries
name, vcs = line.split('@', 1) name, uri = line.split('@', 1)
name = name.strip() name = name.strip()
vcs = vcs.strip() uri = uri.strip()
# noinspection PyBroadException # noinspection PyBroadException
try: try:
# check if the name is valid & parsed # check if the name is valid & parsed
Req.parse(name) Req.parse(name)
# if we are here, name is a valid package name, check if the vcs part is valid # if we are here, name is a valid package name, check if the vcs part is valid
if VCS_REGEX.match(vcs): if VCS_REGEX.match(uri):
req = cls.parse_line(vcs) req = cls.parse_line(uri)
req.name = name req.name = name
return req return req
elif URI_REGEX.match(uri):
req = cls.parse_line(uri)
req.name = name
req.line = line
return req
except Exception: except Exception:
pass pass