Skip to content

Commit 134ed7f

Browse files
authored
Merge pull request #358 from hauntsaninja/fixurl
Fix requirement produced for git URL in extra
2 parents fef1016 + d890067 commit 134ed7f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v4.8.3
2+
======
3+
4+
* #357: Fixed requirement generation from egg-info when a
5+
URL requirement is given.
6+
17
v4.8.2
28
======
39

importlib_metadata/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,16 +696,25 @@ def _convert_egg_info_reqs_to_simple_reqs(sections):
696696
def make_condition(name):
697697
return name and f'extra == "{name}"'
698698

699-
def parse_condition(section):
699+
def quoted_marker(section):
700700
section = section or ''
701701
extra, sep, markers = section.partition(':')
702702
if extra and markers:
703703
markers = f'({markers})'
704704
conditions = list(filter(None, [markers, make_condition(extra)]))
705705
return '; ' + ' and '.join(conditions) if conditions else ''
706706

707+
def url_req_space(req):
708+
"""
709+
PEP 508 requires a space between the url_spec and the quoted_marker.
710+
Ref python/importlib_metadata#357.
711+
"""
712+
# '@' is uniquely indicative of a url_req.
713+
return ' ' * ('@' in req)
714+
707715
for section in sections:
708-
yield section.value + parse_condition(section.name)
716+
space = url_req_space(section.value)
717+
yield section.value + space + quoted_marker(section.name)
709718

710719

711720
class DistributionFinder(MetaPathFinder):

tests/test_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def test_more_complex_deps_requires_text(self):
245245
246246
[extra1]
247247
dep4
248+
dep6@ git+https://example.com/python/[email protected]
248249
249250
[extra2:python_version < "3"]
250251
dep5
@@ -257,6 +258,7 @@ def test_more_complex_deps_requires_text(self):
257258
'dep3; python_version < "3"',
258259
'dep4; extra == "extra1"',
259260
'dep5; (python_version < "3") and extra == "extra2"',
261+
'dep6@ git+https://example.com/python/[email protected] ; extra == "extra1"',
260262
]
261263
# It's important that the environment marker expression be
262264
# wrapped in parentheses to avoid the following 'and' binding more

0 commit comments

Comments
 (0)