Skip to content

Address #5031: freeze non-vcs editable installs as editable #5905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/5031.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Editable, non-VCS installs now freeze as editable.
10 changes: 9 additions & 1 deletion src/pip/_internal/operations/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions tests/functional/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ def fake_install(pkgname, dest):
)


@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"""
Expand Down