Exemplo n.º 1
0
    def __init__(
            self,
            preparer,  # type: RequirementPreparer
            session,  # type: PipSession
            finder,  # type: PackageFinder
            make_install_req,  # type: InstallRequirementProvider
            use_user_site,  # type: bool
            ignore_dependencies,  # type: bool
            ignore_installed,  # type: bool
            ignore_requires_python,  # type: bool
            force_reinstall,  # type: bool
            upgrade_strategy,  # type: str
            py_version_info=None,  # type: Optional[Tuple[int, ...]]
            ignore_compatibility=False,  # type: bool
    ):
        # type: (...) -> None
        super(Resolver, self).__init__()
        assert upgrade_strategy in self._allowed_strategies

        if py_version_info is None:
            py_version_info = sys.version_info[:3]
        else:
            py_version_info = normalize_version_info(py_version_info)

        self._py_version_info = py_version_info

        self.preparer = preparer
        self.finder = finder
        self.session = session

        # This is set in resolve
        self.require_hashes = None  # type: Optional[bool]

        self.upgrade_strategy = upgrade_strategy
        self.force_reinstall = force_reinstall
        self.ignore_dependencies = ignore_dependencies
        self.ignore_installed = ignore_installed
        self.ignore_requires_python = ignore_requires_python
        self.use_user_site = use_user_site
        self._make_install_req = make_install_req
        self.ignore_compatibility = ignore_compatibility
        self.requires_python = None
        if self.ignore_compatibility:
            self.ignore_requires_python = True

        self._discovered_dependencies = \
            defaultdict(list)  # type: DefaultDict[str, List]
Exemplo n.º 2
0
    def __init__(
        self,
        platform=None,  # type: Optional[str]
        py_version_info=None,  # type: Optional[Tuple[int, ...]]
        abi=None,  # type: Optional[str]
        implementation=None,  # type: Optional[str]
    ):
        # type: (...) -> None
        """
        :param platform: A string or None. If None, searches for packages
            that are supported by the current system. Otherwise, will find
            packages that can be built on the platform passed in. These
            packages will only be downloaded for distribution: they will
            not be built locally.
        :param py_version_info: An optional tuple of ints representing the
            Python version information to use (e.g. `sys.version_info[:3]`).
            This can have length 1, 2, or 3 when provided.
        :param abi: A string or None. This is passed to pep425tags.py's
            get_supported() function as is.
        :param implementation: A string or None. This is passed to
            pep425tags.py's get_supported() function as is.
        """
        # Store the given py_version_info for when we call get_supported().
        self._given_py_version_info = py_version_info

        if py_version_info is None:
            py_version_info = sys.version_info[:3]
        else:
            py_version_info = normalize_version_info(py_version_info)

        py_version = '.'.join(map(str, py_version_info[:2]))

        self.abi = abi
        self.implementation = implementation
        self.platform = platform
        self.py_version = py_version
        self.py_version_info = py_version_info

        # This is used to cache the return value of get_tags().
        self._valid_tags = None  # type: Optional[List[Pep425Tag]]
Exemplo n.º 3
0
    def __init__(
        self,
        preparer: RequirementPreparer,
        finder: PackageFinder,
        wheel_cache: Optional[WheelCache],
        make_install_req: InstallRequirementProvider,
        use_user_site: bool,
        ignore_dependencies: bool,
        ignore_installed: bool,
        ignore_requires_python: bool,
        force_reinstall: bool,
        upgrade_strategy: str,
        py_version_info: Optional[Tuple[int, ...]] = None,
    ) -> None:
        super().__init__()
        assert upgrade_strategy in self._allowed_strategies

        if py_version_info is None:
            py_version_info = sys.version_info[:3]
        else:
            py_version_info = normalize_version_info(py_version_info)

        self._py_version_info = py_version_info

        self.preparer = preparer
        self.finder = finder
        self.wheel_cache = wheel_cache

        self.upgrade_strategy = upgrade_strategy
        self.force_reinstall = force_reinstall
        self.ignore_dependencies = ignore_dependencies
        self.ignore_installed = ignore_installed
        self.ignore_requires_python = ignore_requires_python
        self.use_user_site = use_user_site
        self._make_install_req = make_install_req

        self._discovered_dependencies: DiscoveredDependencies = defaultdict(
            list)
Exemplo n.º 4
0
 def __init__(self, py_version_info: Optional[Tuple[int, ...]]) -> None:
     if py_version_info is not None:
         version_info = normalize_version_info(py_version_info)
     else:
         version_info = sys.version_info[:3]
     self._version = Version(".".join(str(c) for c in version_info))