diff --git a/src/pip/_internal/commands/show.py b/src/pip/_internal/commands/show.py index c1aa0e07a4c..98abc9ba2d6 100644 --- a/src/pip/_internal/commands/show.py +++ b/src/pip/_internal/commands/show.py @@ -112,7 +112,7 @@ def _files_from_legacy(dist: BaseDistribution) -> Optional[Iterator[str]]: info = dist.metadata_directory if root is None or info is None: return paths - return (str(pathlib.Path(info, p).resolve().relative_to(root)) for p in paths) + return (str(pathlib.Path(info, p).relative_to(root)) for p in paths) for query_name in query_names: try: diff --git a/src/pip/_internal/metadata/base.py b/src/pip/_internal/metadata/base.py index 950678d4d55..9fdc123ced9 100644 --- a/src/pip/_internal/metadata/base.py +++ b/src/pip/_internal/metadata/base.py @@ -57,18 +57,26 @@ def location(self) -> Optional[str]: A string value is not necessarily a filesystem path, since distributions can be loaded from other sources, e.g. arbitrary zip archives. ``None`` means the distribution is created in-memory. + + Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If + this is a symbolic link, we want to preserve the relative path between + it and files in the distribution. """ raise NotImplementedError() @property - def metadata_directory(self) -> Optional[str]: - """Location of the metadata directory. + def info_directory(self) -> Optional[str]: + """Location of the .[egg|dist]-info directory. Similarly to ``location``, a string value is not necessarily a filesystem path. ``None`` means the distribution is created in-memory. For a modern .dist-info installation on disk, this should be something like ``{location}/{raw_name}-{version}.dist-info``. + + Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If + this is a symbolic link, we want to preserve the relative path between + it and other files in the distribution. """ raise NotImplementedError() diff --git a/src/pip/_internal/metadata/pkg_resources.py b/src/pip/_internal/metadata/pkg_resources.py index 4847ae37e8d..59460062e47 100644 --- a/src/pip/_internal/metadata/pkg_resources.py +++ b/src/pip/_internal/metadata/pkg_resources.py @@ -49,7 +49,7 @@ def location(self) -> Optional[str]: return self._dist.location @property - def metadata_directory(self) -> Optional[str]: + def info_directory(self) -> Optional[str]: return self._dist.egg_info @property