Skip to content

Commit

Permalink
Allow PEP 508 URL spec as editable
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Jan 18, 2021
1 parent 3af9093 commit bc6fecd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/1289.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support to install a PEP 508 URL-specified requirement as editable.
19 changes: 16 additions & 3 deletions src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,24 @@ def parse_editable(editable_req):
- a requirement name
- an URL
- extras
- editable options
Accepted requirements:
svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
.[some_extra]
- svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
- local_path[some_extra]
- Foobar[extra] @ svn+http://blahblah@rev#subdirectory=subdir ; markers
"""
try:
req = Requirement(editable_req)
except InvalidRequirement:
pass
else:
if req.url:
# Join the marker back into the name part. This will be parsed out
# later into a Requirement again.
if req.marker:
name = f"{req.name} ; {req.marker}"
else:
name = req.name
return (name, req.url, req.extras)

url = editable_req

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,14 @@ def test_parse_editable_vcs_extras():
)


def test_parse_editable_pep508():
assert parse_editable('foo[extra] @ svn+http://foo ; os_name == "nt"') == (
'foo ; os_name == "nt"',
'svn+http://foo',
{'extra'},
)


@patch('pip._internal.req.req_install.os.path.abspath')
@patch('pip._internal.req.req_install.os.path.exists')
@patch('pip._internal.req.req_install.os.path.isdir')
Expand Down

0 comments on commit bc6fecd

Please sign in to comment.