Merge pull request #9050 from sbidoul/fix-freeze-direct_url-editable-sbi

This commit is contained in:
Pradyun Gedam 2020-10-27 19:34:10 +05:30 committed by GitHub
commit b39aeeb6df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

3
news/8996.bugfix.rst Normal file
View File

@ -0,0 +1,3 @@
Do not fail in pip freeze when encountering a ``direct_url.json`` metadata file
with editable=True. Render it as a non-editable ``file://`` URL until modern
editable installs are standardized and supported.

View File

@ -43,10 +43,6 @@ def direct_url_as_pep440_direct_reference(direct_url, name):
fragments.append(direct_url.info.hash)
else:
assert isinstance(direct_url.info, DirInfo)
# pip should never reach this point for editables, since
# pip freeze inspects the editable project location to produce
# the requirement string
assert not direct_url.info.editable
requirement += direct_url.url
if direct_url.subdirectory:
fragments.append("subdirectory=" + direct_url.subdirectory)

View File

@ -55,6 +55,21 @@ def test_as_pep440_requirement_dir():
)
def test_as_pep440_requirement_editable_dir():
# direct_url_as_pep440_direct_reference behaves the same
# irrespective of the editable flag. It's the responsibility of
# callers to render it as editable
direct_url = DirectUrl(
url="file:///home/user/project",
info=DirInfo(editable=True),
)
direct_url.validate()
assert (
direct_url_as_pep440_direct_reference(direct_url, "pkg") ==
"pkg @ file:///home/user/project"
)
def test_as_pep440_requirement_vcs():
direct_url = DirectUrl(
url="https:///g.c/u/p.git",