Path: blob/master/venv/Lib/site-packages/pip/_internal/distributions/base.py
811 views
import abc12from pip._vendor.six import add_metaclass34from pip._internal.utils.typing import MYPY_CHECK_RUNNING56if MYPY_CHECK_RUNNING:7from typing import Optional89from pip._vendor.pkg_resources import Distribution10from pip._internal.req import InstallRequirement11from pip._internal.index.package_finder import PackageFinder121314@add_metaclass(abc.ABCMeta)15class AbstractDistribution(object):16"""A base class for handling installable artifacts.1718The requirements for anything installable are as follows:1920- we must be able to determine the requirement name21(or we can't correctly handle the non-upgrade case).2223- for packages with setup requirements, we must also be able24to determine their requirements without installing additional25packages (for the same reason as run-time dependencies)2627- we must be able to create a Distribution object exposing the28above metadata.29"""3031def __init__(self, req):32# type: (InstallRequirement) -> None33super(AbstractDistribution, self).__init__()34self.req = req3536@abc.abstractmethod37def get_pkg_resources_distribution(self):38# type: () -> Optional[Distribution]39raise NotImplementedError()4041@abc.abstractmethod42def prepare_distribution_metadata(self, finder, build_isolation):43# type: (PackageFinder, bool) -> None44raise NotImplementedError()454647