Skip to content

Commit

Permalink
Remove the ability to uninstall distutils installed projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Mar 20, 2017
1 parent ffac1c2 commit fabb739
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions news/2386.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Removed support for uninstalling projects which have been installed using
distutils. distutils installed projects do not include metadata indicating
what files belong to that install and thus it is impossible to *actually*
install them rather than just remove the metadata saying they've been installed
while leaving all of the actual files behind.
15 changes: 6 additions & 9 deletions pip/req/req_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
egg_link_path, FakeFile,
renames, normalize_path, dist_is_local,
)
from pip.utils.deprecation import RemovedInPip10Warning
from pip.utils.logging import indent_log


Expand Down Expand Up @@ -274,15 +273,13 @@ def from_dist(cls, dist):
paths_to_remove.add(path + '.pyo')

elif distutils_egg_info:
warnings.warn(
"Uninstalling a distutils installed project ({0}) has been "
"deprecated and will be removed in a future version. This is "
"due to the fact that uninstalling a distutils project will "
"only partially uninstall the project.".format(
dist.project_name),
RemovedInPip10Warning,
raise UninstallationError(
"Cannot uninstall {!r}. It is a distutils installed project "
"and thus we cannot accurately determine which files belong "
"to it which would lead to only a partial uninstall.".format(
dist.project_name,
)
)
paths_to_remove.add(distutils_egg_info)

elif dist.location.endswith('.egg'):
# package installed by easy_install
Expand Down
11 changes: 7 additions & 4 deletions tests/functional/test_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ def test_simple_uninstall_distutils(script):
result = script.pip('list', '--format=json')
assert {"name": "distutils-install", "version": "0.1"} \
in json.loads(result.stdout)
script.pip('uninstall', 'distutils_install', '-y', expect_stderr=True)
result2 = script.pip('list', '--format=json')
assert {"name": "distutils-install", "version": "0.1"} \
not in json.loads(result2.stdout)
result = script.pip('uninstall', 'distutils_install', '-y',
expect_stderr=True, expect_error=True)
assert result.stderr.strip() == (
"Cannot uninstall 'distutils-install'. It is a distutils installed "
"project and thus we cannot accurately determine which files belong "
"to it which would lead to only a partial uninstall."
)


@pytest.mark.network
Expand Down

0 comments on commit fabb739

Please sign in to comment.