Skip to content

Commit bc6fecd

Browse files
committed
Allow PEP 508 URL spec as editable
1 parent 3af9093 commit bc6fecd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

news/1289.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support to install a PEP 508 URL-specified requirement as editable.

src/pip/_internal/req/constructors.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,24 @@ def parse_editable(editable_req):
7171
- a requirement name
7272
- an URL
7373
- extras
74-
- editable options
7574
Accepted requirements:
76-
svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
77-
.[some_extra]
75+
- svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
76+
- local_path[some_extra]
77+
- Foobar[extra] @ svn+http://blahblah@rev#subdirectory=subdir ; markers
7878
"""
79+
try:
80+
req = Requirement(editable_req)
81+
except InvalidRequirement:
82+
pass
83+
else:
84+
if req.url:
85+
# Join the marker back into the name part. This will be parsed out
86+
# later into a Requirement again.
87+
if req.marker:
88+
name = f"{req.name} ; {req.marker}"
89+
else:
90+
name = req.name
91+
return (name, req.url, req.extras)
7992

8093
url = editable_req
8194

tests/unit/test_req.py

+8
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,14 @@ def test_parse_editable_vcs_extras():
606606
)
607607

608608

609+
def test_parse_editable_pep508():
610+
assert parse_editable('foo[extra] @ svn+http://foo ; os_name == "nt"') == (
611+
'foo ; os_name == "nt"',
612+
'svn+http://foo',
613+
{'extra'},
614+
)
615+
616+
609617
@patch('pip._internal.req.req_install.os.path.abspath')
610618
@patch('pip._internal.req.req_install.os.path.exists')
611619
@patch('pip._internal.req.req_install.os.path.isdir')

0 commit comments

Comments
 (0)