__init__.py 959 B

123456789101112131415161718192021222324
  1. from pip._internal.distributions.sdist import SourceDistribution
  2. from pip._internal.distributions.wheel import WheelDistribution
  3. from pip._internal.utils.typing import MYPY_CHECK_RUNNING
  4. if MYPY_CHECK_RUNNING:
  5. from pip._internal.distributions.base import AbstractDistribution
  6. from pip._internal.req.req_install import InstallRequirement
  7. def make_distribution_for_install_requirement(install_req):
  8. # type: (InstallRequirement) -> AbstractDistribution
  9. """Returns a Distribution for the given InstallRequirement
  10. """
  11. # Editable requirements will always be source distributions. They use the
  12. # legacy logic until we create a modern standard for them.
  13. if install_req.editable:
  14. return SourceDistribution(install_req)
  15. # If it's a wheel, it's a WheelDistribution
  16. if install_req.is_wheel:
  17. return WheelDistribution(install_req)
  18. # Otherwise, a SourceDistribution
  19. return SourceDistribution(install_req)