Skip to content

Commit

Permalink
Don't canonicalize paths in a distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Jul 30, 2021
1 parent d0ce82a commit 662f20a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions src/pip/_internal/metadata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/metadata/pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 662f20a

Please sign in to comment.