Skip to content

Commit dd8a117

Browse files
committed
Don't canonicalize paths in a distribution
1 parent d0ce82a commit dd8a117

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/pip/_internal/commands/show.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ def _files_from_legacy(dist: BaseDistribution) -> Optional[Iterator[str]]:
109109
return None
110110
paths = (p for p in text.splitlines(keepends=False) if p)
111111
root = dist.location
112-
info = dist.metadata_directory
112+
info = dist.info_directory
113113
if root is None or info is None:
114114
return paths
115-
return (str(pathlib.Path(info, p).resolve().relative_to(root)) for p in paths)
115+
return (str(pathlib.Path(info, p).relative_to(root)) for p in paths)
116116

117117
for query_name in query_names:
118118
try:

src/pip/_internal/metadata/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,26 @@ def location(self) -> Optional[str]:
5757
A string value is not necessarily a filesystem path, since distributions
5858
can be loaded from other sources, e.g. arbitrary zip archives. ``None``
5959
means the distribution is created in-memory.
60+
61+
Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
62+
this is a symbolic link, we want to preserve the relative path between
63+
it and files in the distribution.
6064
"""
6165
raise NotImplementedError()
6266

6367
@property
64-
def metadata_directory(self) -> Optional[str]:
65-
"""Location of the metadata directory.
68+
def info_directory(self) -> Optional[str]:
69+
"""Location of the .[egg|dist]-info directory.
6670
6771
Similarly to ``location``, a string value is not necessarily a
6872
filesystem path. ``None`` means the distribution is created in-memory.
6973
7074
For a modern .dist-info installation on disk, this should be something
7175
like ``{location}/{raw_name}-{version}.dist-info``.
76+
77+
Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
78+
this is a symbolic link, we want to preserve the relative path between
79+
it and other files in the distribution.
7280
"""
7381
raise NotImplementedError()
7482

src/pip/_internal/metadata/pkg_resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def location(self) -> Optional[str]:
4949
return self._dist.location
5050

5151
@property
52-
def metadata_directory(self) -> Optional[str]:
52+
def info_directory(self) -> Optional[str]:
5353
return self._dist.egg_info
5454

5555
@property

0 commit comments

Comments
 (0)