m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

6 months ago
  1. from typing import Optional
  2. from pip._vendor.packaging.utils import canonicalize_name
  3. from pip._internal.distributions.base import AbstractDistribution
  4. from pip._internal.index.package_finder import PackageFinder
  5. from pip._internal.metadata import (
  6. BaseDistribution,
  7. FilesystemWheel,
  8. get_wheel_distribution,
  9. )
  10. class WheelDistribution(AbstractDistribution):
  11. """Represents a wheel distribution.
  12. This does not need any preparation as wheels can be directly unpacked.
  13. """
  14. @property
  15. def build_tracker_id(self) -> Optional[str]:
  16. return None
  17. def get_metadata_distribution(self) -> BaseDistribution:
  18. """Loads the metadata from the wheel file into memory and returns a
  19. Distribution that uses it, not relying on the wheel file or
  20. requirement.
  21. """
  22. assert self.req.local_file_path, "Set as part of preparation during download"
  23. assert self.req.name, "Wheels are never unnamed"
  24. wheel = FilesystemWheel(self.req.local_file_path)
  25. return get_wheel_distribution(wheel, canonicalize_name(self.req.name))
  26. def prepare_distribution_metadata(
  27. self,
  28. finder: PackageFinder,
  29. build_isolation: bool,
  30. check_build_deps: bool,
  31. ) -> None:
  32. pass