Skip to content

Commit

Permalink
Add wheel support to InstallRequirement.get_dist
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Jan 8, 2022
1 parent 7f8a684 commit 2922e34
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
BaseDistribution,
get_default_environment,
get_directory_distribution,
get_wheel_distribution,
)
from pip._internal.metadata.base import FilesystemWheel
from pip._internal.models.link import Link
from pip._internal.operations.build.metadata import generate_metadata
from pip._internal.operations.build.metadata_editable import generate_editable_metadata
Expand Down Expand Up @@ -547,7 +549,15 @@ def metadata(self) -> Any:
return self._metadata

def get_dist(self) -> BaseDistribution:
return get_directory_distribution(self.metadata_directory)
if self.metadata_directory:
return get_directory_distribution(self.metadata_directory)
elif self.local_file_path and self.is_wheel:
return get_wheel_distribution(
FilesystemWheel(self.local_file_path), canonicalize_name(self.name)
)
raise AssertionError(
"No metadata directory and no wheel: can't make a distribution."
)

def assert_source_matches_version(self) -> None:
assert self.source_dir
Expand Down

0 comments on commit 2922e34

Please sign in to comment.