Skip to content
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

[issue 1548] Make pip install -e uninstall existing versions #1552

Closed
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
Empty file added .trigger-travis
Empty file.
7 changes: 7 additions & 0 deletions pip/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,13 @@ def check_if_exists(self):
return True
else:
self.satisfied_by = pkg_resources.get_distribution(self.req)

if self.editable and self.satisfied_by:
self.conflicts_with = self.satisfied_by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to set self.satisfied_by back to None after this.
and add a comment that says something like "when installing editables, nothing pre-existing should ever satisfy"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, see 5b62075. Thanks!

# when installing editables, nothing pre-existing should ever
# satisfy
self.satisfied_by = None
return True
except pkg_resources.DistributionNotFound:
return False
except pkg_resources.VersionConflict:
Expand Down
2 changes: 1 addition & 1 deletion pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
## Search for archive to fulfill requirement ##
###############################################

if not self.ignore_installed and not req_to_install.editable:
if not self.ignore_installed:
req_to_install.check_if_exists()
if req_to_install.satisfied_by:
if self.upgrade:
Expand Down
26 changes: 26 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,32 @@ def test_install_editable_from_git(script, tmpdir):
result.assert_installed('pip-test-package', with_files=['.git'])


def test_install_editable_uninstalls_existing(data, script, tmpdir):
"""
Test that installing an editable uninstalls a previously installed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a second test that deals with a non-vcs "-e " install would be ideal, to confirm that also works as we'd want.

non-editable version.
https://github.com/pypa/pip/issues/1548
https://github.com/pypa/pip/pull/1552
"""
to_install = data.packages.join("pip-test-package-0.1.tar.gz")
result = script.pip_install_local(to_install)
assert 'Successfully installed pip-test-package' in result.stdout
result.assert_installed('piptestpackage', editable=False)

result = script.pip(
'install', '-e',
'%s#egg=pip-test-package' %
local_checkout(
'git+http://github.com/pypa/pip-test-package.git',
tmpdir.join("cache"),
),
)
result.assert_installed('pip-test-package', with_files=['.git'])
assert 'Found existing installation: pip-test-package 0.1' in result.stdout
assert 'Uninstalling pip-test-package:' in result.stdout
assert 'Successfully uninstalled pip-test-package' in result.stdout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, would be better if you could confirm the package is removed from site-packages using result.files_deleted



def test_install_editable_from_hg(script, tmpdir):
"""
Test cloning from Mercurial.
Expand Down