1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #5905 from cjerdonek/issue-5031-freeze-non-vcs-editable

Address #5031: freeze non-vcs editable installs as editable
This commit is contained in:
Chris Jerdonek 2018-11-05 14:21:42 -08:00 committed by GitHub
commit 3803ce3cb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

1
news/5031.feature Normal file
View file

@ -0,0 +1 @@
Editable, non-VCS installs now freeze as editable.

View file

@ -157,7 +157,15 @@ def get_requirement_info(dist):
vc_type = vcs.get_backend_type(location)
if not vc_type:
return (None, False, [])
req = dist.as_requirement()
logger.debug(
'No VCS found for editable requirement {!r} in: {!r}', req,
location,
)
comments = [
'# Editable, no version control detected ({})'.format(req)
]
return (location, True, comments)
try:
req = vc_type().get_src_requirement(dist, location)

View file

@ -116,6 +116,27 @@ def test_freeze_with_invalid_names(script):
)
@pytest.mark.git
def test_freeze_editable_not_vcs(script, tmpdir):
"""
Test an editable install that is not version controlled.
"""
pkg_path = _create_test_package(script)
# Rename the .git directory so the directory is no longer recognized
# as a VCS directory.
os.rename(os.path.join(pkg_path, '.git'), os.path.join(pkg_path, '.bak'))
script.pip('install', '-e', pkg_path)
result = script.pip('freeze', expect_stderr=True)
# We need to apply os.path.normcase() to the path since that is what
# the freeze code does.
expected = textwrap.dedent("""\
...# Editable, no version control detected (version-pkg==0.1)
-e {}
...""".format(os.path.normcase(pkg_path)))
_check_output(result.stdout, expected)
@pytest.mark.svn
def test_freeze_svn(script, tmpdir):
"""Test freezing a svn checkout"""