def make_condition(name):
return name and 'extra == "{name}"'.format(name=name)
- def parse_condition(section):
+ def quoted_marker(section):
section = section or ''
extra, sep, markers = section.partition(':')
if extra and markers:
- markers = '({markers})'.format(markers=markers)
+ markers = f'({markers})'
conditions = list(filter(None, [markers, make_condition(extra)]))
return '; ' + ' and '.join(conditions) if conditions else ''
+ def url_req_space(req):
+ """
+ PEP 508 requires a space between the url_spec and the quoted_marker.
+ Ref python/importlib_metadata#357.
+ """
+ # '@' is uniquely indicative of a url_req.
+ return ' ' * ('@' in req)
+
for section, deps in sections.items():
for dep in deps:
- yield dep + parse_condition(section)
+ space = url_req_space(dep)
+ yield dep + space + quoted_marker(section)
class DistributionFinder(MetaPathFinder):
[extra1]
dep4
+ dep6@ git+https://example.com/python/dep.git@v1.0.0
[extra2:python_version < "3"]
dep5
'dep3; python_version < "3"',
'dep4; extra == "extra1"',
'dep5; (python_version < "3") and extra == "extra2"',
+ 'dep6@ git+https://example.com/python/dep.git@v1.0.0 ; extra == "extra1"',
]
# It's important that the environment marker expression be
# wrapped in parentheses to avoid the following 'and' binding more