Attempt to get name for editable file:// URLs

When installing an editable from file:///path/to/file, pip currently does
not attempt to determine the name from #egg=NAME, just passing back
None.  This causes constraints code to completely ignore this line
resulting in unexpected installation behaviour.

This patch makes '-e file:///path#egg=name' function similarly to
'file:///path#egg=name' and '-e git+URL#egg=name'.  If #egg=name is not
defined, it returns None and the package becomes an unamed requirement,
which constraints will not parse but in the case of a requirement will
later be processed and determined.

Closes #3026
This commit is contained in:
Sachi King 2015-08-18 11:25:00 +10:00
parent 4c7fd6aead
commit 5d96864775
2 changed files with 5 additions and 3 deletions

View File

@ -1065,6 +1065,8 @@ def parse_editable(editable_req, default_vcs=None):
.[some_extra]
"""
from pip.index import Link
url = editable_req
extras = None
@ -1086,9 +1088,10 @@ def parse_editable(editable_req, default_vcs=None):
url_no_extras = path_to_url(url_no_extras)
if url_no_extras.lower().startswith('file:'):
package_name = Link(url_no_extras).egg_fragment
if extras:
return (
None,
package_name,
url_no_extras,
pkg_resources.Requirement.parse(
'__placeholder__' + extras
@ -1096,7 +1099,7 @@ def parse_editable(editable_req, default_vcs=None):
{},
)
else:
return None, url_no_extras, None, {}
return package_name, url_no_extras, None, {}
for version_control in vcs:
if url.lower().startswith('%s:' % version_control):

View File

@ -282,7 +282,6 @@ def test_constraints_local_install_causes_error(script, data):
assert 'Could not satisfy constraints for' in result.stderr
@pytest.mark.xfail
def test_constraints_constrain_to_local_editable(script, data):
to_install = data.src.join("singlemodule")
script.scratch_path.join("constraints.txt").write(