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.

51 lines
1.7 KiB

6 months ago
  1. import abc
  2. from typing import Optional
  3. from pip._internal.index.package_finder import PackageFinder
  4. from pip._internal.metadata.base import BaseDistribution
  5. from pip._internal.req import InstallRequirement
  6. class AbstractDistribution(metaclass=abc.ABCMeta):
  7. """A base class for handling installable artifacts.
  8. The requirements for anything installable are as follows:
  9. - we must be able to determine the requirement name
  10. (or we can't correctly handle the non-upgrade case).
  11. - for packages with setup requirements, we must also be able
  12. to determine their requirements without installing additional
  13. packages (for the same reason as run-time dependencies)
  14. - we must be able to create a Distribution object exposing the
  15. above metadata.
  16. - if we need to do work in the build tracker, we must be able to generate a unique
  17. string to identify the requirement in the build tracker.
  18. """
  19. def __init__(self, req: InstallRequirement) -> None:
  20. super().__init__()
  21. self.req = req
  22. @abc.abstractproperty
  23. def build_tracker_id(self) -> Optional[str]:
  24. """A string that uniquely identifies this requirement to the build tracker.
  25. If None, then this dist has no work to do in the build tracker, and
  26. ``.prepare_distribution_metadata()`` will not be called."""
  27. raise NotImplementedError()
  28. @abc.abstractmethod
  29. def get_metadata_distribution(self) -> BaseDistribution:
  30. raise NotImplementedError()
  31. @abc.abstractmethod
  32. def prepare_distribution_metadata(
  33. self,
  34. finder: PackageFinder,
  35. build_isolation: bool,
  36. check_build_deps: bool,
  37. ) -> None:
  38. raise NotImplementedError()