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

Properly normalize and handle linked dist

This commit is contained in:
Tzu-ping Chung 2021-12-13 03:33:06 +08:00
parent eea84b33fb
commit 8073f65c14
3 changed files with 8 additions and 4 deletions

View file

@ -26,6 +26,7 @@ from pip._internal.metadata.base import (
InfoPath,
Wheel,
)
from pip._internal.utils.misc import normalize_path
from pip._internal.utils.packaging import safe_extra
from pip._internal.utils.wheel import parse_wheel, read_wheel_metadata_file
@ -141,7 +142,7 @@ class Distribution(BaseDistribution):
def installed_location(self) -> Optional[str]:
if self._installed_location is None:
return None
return str(self._installed_location)
return normalize_path(str(self._installed_location))
def _get_dist_name_from_location(self) -> Optional[str]:
"""Try to get the name from the metadata directory name.

View file

@ -151,10 +151,11 @@ class Environment(BaseEnvironment):
finder = _DistributionFinder()
for location in self._paths:
yield from finder.find(location)
yield from finder.find_linked(location)
for dist in finder.find_eggs(location):
# _emit_egg_deprecation(dist.location) # TODO: Enable this.
yield dist
# This must go last because that's how pkg_resources tie-breaks.
yield from finder.find_linked(location)
def get_distribution(self, name: str) -> Optional[BaseDistribution]:
matches = (

View file

@ -615,11 +615,13 @@ def test_uninstall_setuptools_develop_install(
script.assert_installed(FSPkg="0.1.dev0")
# Uninstall both develop and install
uninstall = script.pip("uninstall", "FSPkg", "-y")
assert any(filename.endswith(".egg") for filename in uninstall.files_deleted.keys())
assert any(filename.endswith(".egg") for filename in uninstall.files_deleted), str(
uninstall
)
uninstall2 = script.pip("uninstall", "FSPkg", "-y")
assert (
join(script.site_packages, "FSPkg.egg-link") in uninstall2.files_deleted
), list(uninstall2.files_deleted.keys())
), str(uninstall2)
script.assert_not_installed("FSPkg")