コード例 #1
0
ファイル: test_index.py プロジェクト: hrnciar/pip
    def test_create__link_collector(self) -> None:
        """
        Test that the _link_collector attribute is set correctly.
        """
        link_collector = LinkCollector(
            session=PipSession(),
            search_scope=SearchScope([], []),
        )
        finder = PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=SelectionPreferences(allow_yanked=True),
        )

        assert finder._link_collector is link_collector
コード例 #2
0
def get_finder() -> PackageFinder:
    return PackageFinder.create(
        LinkCollector.create(
            session=PipSession(),
            options=Values(defaults=dict(
                no_index=False, index_url="https://pypi.python.org/simple",
                find_links=None, extra_index_urls=[""]))
        ),
        SelectionPreferences(
            allow_yanked=False,
            allow_all_prereleases=True
        ),
        use_deprecated_html5lib=False,
    )
コード例 #3
0
ファイル: test_index.py プロジェクト: warejohn/pip
 def test_create__target_python_none(self):
     """
     Test passing target_python=None.
     """
     finder = PackageFinder.create(
         search_scope=SearchScope([], []),
         selection_prefs=SelectionPreferences(allow_yanked=True),
         session=PipSession(),
         target_python=None,
     )
     # Spot-check the default TargetPython object.
     actual_target_python = finder._target_python
     assert actual_target_python._given_py_version_info is None
     assert actual_target_python.py_version_info == CURRENT_PY_VERSION_INFO
コード例 #4
0
 def test_create__allow_yanked(self, allow_yanked):
     """
     Test that the _allow_yanked attribute is set correctly.
     """
     link_collector = LinkCollector(
         session=PipSession(),
         search_scope=SearchScope([], []),
     )
     selection_prefs = SelectionPreferences(allow_yanked=allow_yanked)
     finder = PackageFinder.create(
         link_collector=link_collector,
         selection_prefs=selection_prefs,
     )
     assert finder._allow_yanked == allow_yanked
コード例 #5
0
 def test_create__ignore_requires_python(self, ignore_requires_python):
     """
     Test that the _ignore_requires_python attribute is set correctly.
     """
     selection_prefs = SelectionPreferences(
         allow_yanked=True,
         ignore_requires_python=ignore_requires_python,
     )
     finder = PackageFinder.create(
         search_scope=SearchScope([], []),
         selection_prefs=selection_prefs,
         session=PipSession(),
     )
     assert finder._ignore_requires_python == ignore_requires_python
コード例 #6
0
    def test_create__link_collector(self):
        """
        Test that the _link_collector attribute is set correctly.
        """
        search_scope = SearchScope([], [])
        session = PipSession()
        finder = PackageFinder.create(
            search_scope=search_scope,
            selection_prefs=SelectionPreferences(allow_yanked=True),
            session=session,
        )

        actual_link_collector = finder._link_collector
        assert actual_link_collector.search_scope is search_scope
        assert actual_link_collector.session is session
コード例 #7
0
    def _build_package_finder(self, options, session):
        # type: (Values, PipSession) -> PackageFinder
        """
        Create a package finder appropriate to this list command.
        """
        link_collector = LinkCollector.create(session, options=options)

        # Pass allow_yanked=False to ignore yanked versions.
        selection_prefs = SelectionPreferences(
            allow_yanked=False, allow_all_prereleases=options.pre
        )

        return PackageFinder.create(
            link_collector=link_collector, selection_prefs=selection_prefs
        )
コード例 #8
0
 def test_create__target_python(self):
     """
     Test that the _target_python attribute is set correctly.
     """
     target_python = TargetPython(py_version_info=(3, 7, 3))
     finder = PackageFinder.create(
         search_scope=SearchScope([], []),
         selection_prefs=SelectionPreferences(allow_yanked=True),
         session=PipSession(),
         target_python=target_python,
     )
     actual_target_python = finder._target_python
     # The target_python attribute should be set as is.
     assert actual_target_python is target_python
     # Check that the attributes weren't reset.
     assert actual_target_python.py_version_info == (3, 7, 3)
コード例 #9
0
    def _get_finder():
        try:
            return PackageFinder(find_links=[],
                                 index_urls=[],
                                 session=PipSession())
        except TypeError:
            pass

        from pip._internal.models.search_scope import SearchScope
        from pip._internal.models.selection_prefs import SelectionPreferences

        return PackageFinder.create(
            search_scope=SearchScope(find_links=[], index_urls=[]),
            selection_prefs=SelectionPreferences(allow_yanked=False),
            session=PipSession(),
        )
コード例 #10
0
    def _build_package_finder(self, options, session):
        """
        Create a package finder appropriate to this list command.
        """
        search_scope = make_search_scope(options)

        # Pass allow_yanked=False to ignore yanked versions.
        selection_prefs = SelectionPreferences(
            allow_yanked=False,
            allow_all_prereleases=options.pre,
        )

        return PackageFinder.create(
            search_scope=search_scope,
            selection_prefs=selection_prefs,
            session=session,
        )
コード例 #11
0
ファイル: test_index.py プロジェクト: tysonclugg/pip
 def test_create__target_python(self):
     """
     Test that target_python is passed to CandidateEvaluator as is.
     """
     search_scope = SearchScope([], [])
     selection_prefs = SelectionPreferences(allow_yanked=True, )
     target_python = TargetPython(py_version_info=(3, 7, 3))
     finder = PackageFinder.create(
         search_scope=search_scope,
         selection_prefs=selection_prefs,
         session=object(),
         target_python=target_python,
     )
     evaluator = finder.candidate_evaluator
     actual_target_python = evaluator._target_python
     assert actual_target_python is target_python
     assert actual_target_python.py_version_info == (3, 7, 3)
コード例 #12
0
ファイル: test_index.py プロジェクト: sailfishos-mirror/pip
 def test_create__ignore_requires_python(self, ignore_requires_python: bool) -> None:
     """
     Test that the _ignore_requires_python attribute is set correctly.
     """
     link_collector = LinkCollector(
         session=PipSession(),
         search_scope=SearchScope([], []),
     )
     selection_prefs = SelectionPreferences(
         allow_yanked=True,
         ignore_requires_python=ignore_requires_python,
     )
     finder = PackageFinder.create(
         link_collector=link_collector,
         selection_prefs=selection_prefs,
         use_deprecated_html5lib=False,
     )
     assert finder._ignore_requires_python == ignore_requires_python
コード例 #13
0
 def test_create__format_control(self):
     """
     Test that the format_control attribute is set correctly.
     """
     format_control = FormatControl(set(), {':all:'})
     selection_prefs = SelectionPreferences(
         allow_yanked=True,
         format_control=format_control,
     )
     finder = PackageFinder.create(
         search_scope=SearchScope([], []),
         selection_prefs=selection_prefs,
         session=PipSession(),
     )
     actual_format_control = finder.format_control
     assert actual_format_control is format_control
     # Check that the attributes weren't reset.
     assert actual_format_control.only_binary == {':all:'}
コード例 #14
0
ファイル: test_index.py プロジェクト: sailfishos-mirror/pip
 def test_create__target_python_none(self) -> None:
     """
     Test passing target_python=None.
     """
     link_collector = LinkCollector(
         session=PipSession(),
         search_scope=SearchScope([], []),
     )
     finder = PackageFinder.create(
         link_collector=link_collector,
         selection_prefs=SelectionPreferences(allow_yanked=True),
         target_python=None,
         use_deprecated_html5lib=False,
     )
     # Spot-check the default TargetPython object.
     actual_target_python = finder._target_python
     assert actual_target_python._given_py_version_info is None
     assert actual_target_python.py_version_info == CURRENT_PY_VERSION_INFO
コード例 #15
0
    def _build_package_finder(self, options: Values,
                              session: PipSession) -> PackageFinder:
        """
        Create a package finder appropriate to this list command.
        """
        link_collector = LinkCollector.create(session, options=options)

        # Pass allow_yanked=False to ignore yanked versions.
        selection_prefs = SelectionPreferences(
            allow_yanked=False,
            allow_all_prereleases=options.pre,
        )

        return PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=selection_prefs,
            use_deprecated_html5lib="html5lib"
            in options.deprecated_features_enabled,
        )
コード例 #16
0
ファイル: test_index.py プロジェクト: afkmamunbd/pip
    def test_iter_secure_origins__none_trusted_hosts(self):
        """
        Test iter_secure_origins() after passing trusted_hosts=None.
        """
        # Use PackageFinder.create() rather than make_test_finder()
        # to make sure we're really passing trusted_hosts=None.
        search_scope = SearchScope([], [])
        selection_prefs = SelectionPreferences(allow_yanked=True, )
        finder = PackageFinder.create(
            search_scope=search_scope,
            selection_prefs=selection_prefs,
            trusted_hosts=None,
            session=object(),
        )

        actual = list(finder.iter_secure_origins())
        assert len(actual) == 6
        # Spot-check that SECURE_ORIGINS is included.
        assert actual[0] == ('https', '*', '*')
コード例 #17
0
ファイル: test_index.py プロジェクト: zqdely/pip
 def test_create__candidate_prefs(
     self, allow_all_prereleases, prefer_binary,
 ):
     """
     Test that the _candidate_prefs attribute is set correctly.
     """
     selection_prefs = SelectionPreferences(
         allow_yanked=True,
         allow_all_prereleases=allow_all_prereleases,
         prefer_binary=prefer_binary,
     )
     finder = PackageFinder.create(
         search_scope=SearchScope([], []),
         selection_prefs=selection_prefs,
         session=PipSession(),
     )
     candidate_prefs = finder._candidate_prefs
     assert candidate_prefs.allow_all_prereleases == allow_all_prereleases
     assert candidate_prefs.prefer_binary == prefer_binary
コード例 #18
0
ファイル: _pip_compat.py プロジェクト: tulimaki/prequ
        def create_package_finder(**kwargs):
            find_links = kwargs.pop('find_links', None)
            index_urls = kwargs.pop('index_urls', None)
            allow_all_prereleases = kwargs.pop('allow_all_prereleases', None)
            if find_links is not None:
                kwargs.setdefault(
                    'search_scope',
                    SearchScope(
                        find_links=find_links,
                        index_urls=index_urls,
                    ))
            if allow_all_prereleases is not None:
                kwargs.setdefault(
                    'selection_prefs',
                    SelectionPreferences(
                        allow_yanked=True,
                        allow_all_prereleases=allow_all_prereleases,
                    ))

            return PackageFinder.create(**kwargs)
コード例 #19
0
def make_pytorch_packager_finder(
    session: Optional[PipSession] = None,
    target_python: Optional[TargetPython] = None,
    computation_backend: Optional[ComputationBackend] = None,
) -> PackageFinder:
    if session is None:
        session = PipSession()
    if target_python is None:
        target_python = TargetPython()
    if computation_backend is None:
        computation_backend = detect_computation_backend()

    link_collector = make_pytorch_link_collector(session)
    selection_prefs = SelectionPreferences(allow_yanked=True)
    return PytorchPackageFinder.create(
        link_collector=link_collector,
        selection_prefs=selection_prefs,
        target_python=target_python,
        computation_backend=computation_backend,
    )
コード例 #20
0
ファイル: test_index.py プロジェクト: sailfishos-mirror/pip
 def test_create__target_python(self) -> None:
     """
     Test that the _target_python attribute is set correctly.
     """
     link_collector = LinkCollector(
         session=PipSession(),
         search_scope=SearchScope([], []),
     )
     target_python = TargetPython(py_version_info=(3, 7, 3))
     finder = PackageFinder.create(
         link_collector=link_collector,
         selection_prefs=SelectionPreferences(allow_yanked=True),
         target_python=target_python,
         use_deprecated_html5lib=False,
     )
     actual_target_python = finder._target_python
     # The target_python attribute should be set as is.
     assert actual_target_python is target_python
     # Check that the attributes weren't reset.
     assert actual_target_python.py_version_info == (3, 7, 3)
コード例 #21
0
ファイル: base_command.py プロジェクト: tysonclugg/pip
    def _build_package_finder(
            self,
            options,  # type: Values
            session,  # type: PipSession
            platform=None,  # type: Optional[str]
            py_version_info=None,  # type: Optional[Tuple[int, ...]]
            abi=None,  # type: Optional[str]
            implementation=None,  # type: Optional[str]
            ignore_requires_python=None,  # type: Optional[bool]
    ):
        # type: (...) -> PackageFinder
        """
        Create a package finder appropriate to this requirement command.

        :param ignore_requires_python: Whether to ignore incompatible
            "Requires-Python" values in links. Defaults to False.
        """
        search_scope = make_search_scope(options)
        selection_prefs = SelectionPreferences(
            allow_yanked=True,
            format_control=options.format_control,
            allow_all_prereleases=options.pre,
            prefer_binary=options.prefer_binary,
            ignore_requires_python=ignore_requires_python,
        )

        target_python = TargetPython(
            platform=platform,
            py_version_info=py_version_info,
            abi=abi,
            implementation=implementation,
        )

        return PackageFinder.create(
            search_scope=search_scope,
            selection_prefs=selection_prefs,
            trusted_hosts=options.trusted_hosts,
            session=session,
            target_python=target_python,
        )
コード例 #22
0
ファイル: test_index.py プロジェクト: sailfishos-mirror/pip
 def test_create__format_control(self) -> None:
     """
     Test that the format_control attribute is set correctly.
     """
     link_collector = LinkCollector(
         session=PipSession(),
         search_scope=SearchScope([], []),
     )
     format_control = FormatControl(set(), {":all:"})
     selection_prefs = SelectionPreferences(
         allow_yanked=True,
         format_control=format_control,
     )
     finder = PackageFinder.create(
         link_collector=link_collector,
         selection_prefs=selection_prefs,
         use_deprecated_html5lib=False,
     )
     actual_format_control = finder.format_control
     assert actual_format_control is format_control
     # Check that the attributes weren't reset.
     assert actual_format_control.only_binary == {":all:"}
コード例 #23
0
ファイル: test_index.py プロジェクト: nixphix/pip
 def test_create__candidate_evaluator(
     self, allow_all_prereleases, prefer_binary,
 ):
     """
     Test that the candidate_evaluator attribute is set correctly.
     """
     selection_prefs = SelectionPreferences(
         allow_yanked=True,
         allow_all_prereleases=allow_all_prereleases,
         prefer_binary=prefer_binary,
     )
     target_python = TargetPython(py_version_info=(3, 7, 3))
     target_python._valid_tags = ['tag1', 'tag2']
     finder = PackageFinder.create(
         search_scope=SearchScope([], []),
         selection_prefs=selection_prefs,
         session=PipSession(),
         target_python=target_python,
     )
     evaluator = finder.candidate_evaluator
     assert evaluator.allow_all_prereleases == allow_all_prereleases
     assert evaluator._prefer_binary == prefer_binary
     assert evaluator._supported_tags == ['tag1', 'tag2']
コード例 #24
0
ファイル: req_command.py プロジェクト: wikieden/lumberyard
    def _build_package_finder(
            self,
            options,  # type: Values
            session,  # type: PipSession
            target_python=None,  # type: Optional[TargetPython]
            ignore_requires_python=None,  # type: Optional[bool]
    ):

        # type: (...) -> PackageFinder
        """

        Create a package finder appropriate to this requirement command.



        :param ignore_requires_python: Whether to ignore incompatible

            "Requires-Python" values in links. Defaults to False.

        """

        link_collector = LinkCollector.create(session, options=options)

        selection_prefs = SelectionPreferences(
            allow_yanked=True,
            format_control=options.format_control,
            allow_all_prereleases=options.pre,
            prefer_binary=options.prefer_binary,
            ignore_requires_python=ignore_requires_python,
        )

        return PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=selection_prefs,
            target_python=target_python,
        )
コード例 #25
0
    def _build_package_finder(
        self,
        options: Values,
        session: PipSession,
        target_python: Optional[TargetPython] = None,
        ignore_requires_python: Optional[bool] = None,
    ) -> PackageFinder:
        """
        Create a package finder appropriate to the index command.
        """
        link_collector = LinkCollector.create(session, options=options)

        # Pass allow_yanked=False to ignore yanked versions.
        selection_prefs = SelectionPreferences(
            allow_yanked=False,
            allow_all_prereleases=options.pre,
            ignore_requires_python=ignore_requires_python,
        )

        return PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=selection_prefs,
            target_python=target_python,
        )
コード例 #26
0
def pip_self_version_check(session, options):
    # type: (PipSession, optparse.Values) -> None
    """Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    """
    installed_version = get_installed_version("pip")
    if not installed_version:
        return

    pip_version = packaging_version.parse(installed_version)
    pypi_version = None

    try:
        state = SelfCheckState(cache_dir=options.cache_dir)

        current_time = datetime.datetime.utcnow()
        # Determine if we need to refresh the state
        if "last_check" in state.state and "pypi_version" in state.state:
            last_check = datetime.datetime.strptime(state.state["last_check"],
                                                    SELFCHECK_DATE_FMT)
            if (current_time - last_check).total_seconds() < 7 * 24 * 60 * 60:
                pypi_version = state.state["pypi_version"]

        # Refresh the version if we need to or just see if we need to warn
        if pypi_version is None:
            # Lets use PackageFinder to see what the latest pip version is
            link_collector = LinkCollector.create(
                session,
                options=options,
                suppress_no_index=True,
            )

            # Pass allow_yanked=False so we don't suggest upgrading to a
            # yanked version.
            selection_prefs = SelectionPreferences(
                allow_yanked=False,
                allow_all_prereleases=False,  # Explicitly set to False
            )

            finder = PackageFinder.create(
                link_collector=link_collector,
                selection_prefs=selection_prefs,
            )
            best_candidate = finder.find_best_candidate("pip").best_candidate
            if best_candidate is None:
                return
            pypi_version = str(best_candidate.version)

            # save that we've performed a check
            state.save(pypi_version, current_time)

        remote_version = packaging_version.parse(pypi_version)

        local_version_is_older = (
            pip_version < remote_version
            and pip_version.base_version != remote_version.base_version
            and was_installed_by_pip('pip'))

        # Determine if our pypi_version is older
        if not local_version_is_older:
            return

        # We cannot tell how the current pip is available in the current
        # command context, so be pragmatic here and suggest the command
        # that's always available. This does not accommodate spaces in
        # `sys.executable`.
        pip_cmd = "{} -m pip".format(sys.executable)
        logger.warning(
            "You are using pip version %s; however, version %s is "
            "available.\nYou should consider upgrading via the "
            "'%s install --upgrade pip' command.", pip_version, pypi_version,
            pip_cmd)
    except Exception:
        logger.debug(
            "There was an error checking the latest version of pip",
            exc_info=True,
        )
コード例 #27
0
            if (current_time - last_check).total_seconds() < 7 * 24 * 60 * 60:
                pypi_version = state.state["pypi_version"]

        # Refresh the version if we need to or just see if we need to warn
        if pypi_version is None:
            # Lets use PackageFinder to see what the latest pip version is
            link_collector = LinkCollector.create(
                session,
                options=options,
                suppress_no_index=True,
            )

            # Pass allow_yanked=False so we don't suggest upgrading to a
            # yanked version.
            selection_prefs = SelectionPreferences(
                allow_yanked=False,
                allow_all_prereleases=False,  # Explicitly set to False
            )

            finder = PackageFinder.create(
                link_collector=link_collector,
                selection_prefs=selection_prefs,
            )
            best_candidate = finder.find_best_candidate("pip").best_candidate
            if best_candidate is None:
                return
            pypi_version = str(best_candidate.version)

            # save that we've performed a check
            state.save(pypi_version, current_time)

<<<<<<< HEAD
コード例 #28
0
def pip_version_check(session, options):
    # type: (PipSession, optparse.Values) -> None
    """Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    """
    installed_version = get_installed_version("pip")
    if not installed_version:
        return

    pip_version = packaging_version.parse(installed_version)
    pypi_version = None

    try:
        state = SelfCheckState(cache_dir=options.cache_dir)

        current_time = datetime.datetime.utcnow()
        # Determine if we need to refresh the state
        if "last_check" in state.state and "pypi_version" in state.state:
            last_check = datetime.datetime.strptime(state.state["last_check"],
                                                    SELFCHECK_DATE_FMT)
            if (current_time - last_check).total_seconds() < 7 * 24 * 60 * 60:
                pypi_version = state.state["pypi_version"]

        # Refresh the version if we need to or just see if we need to warn
        if pypi_version is None:
            # Lets use PackageFinder to see what the latest pip version is
            search_scope = make_search_scope(options, suppress_no_index=True)

            # Pass allow_yanked=False so we don't suggest upgrading to a
            # yanked version.
            selection_prefs = SelectionPreferences(
                allow_yanked=False,
                allow_all_prereleases=False,  # Explicitly set to False
            )

            finder = PackageFinder.create(
                search_scope=search_scope,
                selection_prefs=selection_prefs,
                session=session,
            )
            best_candidate = finder.find_best_candidate("pip").best_candidate
            if best_candidate is None:
                return
            pypi_version = str(best_candidate.version)

            # save that we've performed a check
            state.save(pypi_version, current_time)

        remote_version = packaging_version.parse(pypi_version)

        local_version_is_older = (
            pip_version < remote_version
            and pip_version.base_version != remote_version.base_version
            and was_installed_by_pip('pip'))

        # Determine if our pypi_version is older
        if not local_version_is_older:
            return

        # Advise "python -m pip" on Windows to avoid issues
        # with overwriting pip.exe.
        if WINDOWS:
            pip_cmd = "python -m pip"
        else:
            pip_cmd = "pip"
        logger.warning(
            "You are using pip version %s, however version %s is "
            "available.\nYou should consider upgrading via the "
            "'%s install --upgrade pip' command.", pip_version, pypi_version,
            pip_cmd)
    except Exception:
        logger.debug(
            "There was an error checking the latest version of pip",
            exc_info=True,
        )
コード例 #29
0
ファイル: self_outdated_check.py プロジェクト: ZekriSara/pfe
def pip_self_version_check(session: PipSession,
                           options: optparse.Values) -> None:
    """Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    """
    installed_dist = get_default_environment().get_distribution("pip")
    if not installed_dist:
        return

    pip_version = installed_dist.version
    pypi_version = None

    try:
        state = SelfCheckState(cache_dir=options.cache_dir)

        current_time = datetime.datetime.utcnow()
        # Determine if we need to refresh the state
        if "last_check" in state.state and "pypi_version" in state.state:
            last_check = datetime.datetime.strptime(state.state["last_check"],
                                                    SELFCHECK_DATE_FMT)
            if (current_time - last_check).total_seconds() < 7 * 24 * 60 * 60:
                pypi_version = state.state["pypi_version"]

        # Refresh the version if we need to or just see if we need to warn
        if pypi_version is None:
            # Lets use PackageFinder to see what the latest pip version is
            link_collector = LinkCollector.create(
                session,
                options=options,
                suppress_no_index=True,
            )

            # Pass allow_yanked=False so we don't suggest upgrading to a
            # yanked version.
            selection_prefs = SelectionPreferences(
                allow_yanked=False,
                allow_all_prereleases=False,  # Explicitly set to False
            )

            finder = PackageFinder.create(
                link_collector=link_collector,
                selection_prefs=selection_prefs,
                use_deprecated_html5lib=(
                    "html5lib" in options.deprecated_features_enabled),
            )
            best_candidate = finder.find_best_candidate("pip").best_candidate
            if best_candidate is None:
                return
            pypi_version = str(best_candidate.version)

            # save that we've performed a check
            state.save(pypi_version, current_time)

        remote_version = parse_version(pypi_version)

        local_version_is_older = (
            pip_version < remote_version
            and pip_version.base_version != remote_version.base_version
            and was_installed_by_pip("pip"))

        # Determine if our pypi_version is older
        if not local_version_is_older:
            return

        # We cannot tell how the current pip is available in the current
        # command context, so be pragmatic here and suggest the command
        # that's always available. This does not accommodate spaces in
        # `sys.executable` on purpose as it is not possible to do it
        # correctly without knowing the user's shell. Thus,
        # it won't be done until possible through the standard library.
        # Do not be tempted to use the undocumented subprocess.list2cmdline.
        # It is considered an internal implementation detail for a reason.
        pip_cmd = f"{sys.executable} -m pip"
        logger.warning(
            "You are using pip version %s; however, version %s is "
            "available.\nYou should consider upgrading via the "
            "'%s install --upgrade pip' command.",
            pip_version,
            pypi_version,
            pip_cmd,
        )
    except Exception:
        logger.debug(
            "There was an error checking the latest version of pip",
            exc_info=True,
        )
コード例 #30
0
            logger.info(locations)

    def _build_package_finder(
        self,
        options,               # type: Values
        session,               # type: PipSession
        target_python=None,    # type: Optional[TargetPython]
        ignore_requires_python=None,  # type: Optional[bool]
    ):
        # type: (...) -> PackageFinder
        """
        Create a package finder appropriate to this requirement command.

        :param ignore_requires_python: Whether to ignore incompatible
            "Requires-Python" values in links. Defaults to False.
        """
        link_collector = LinkCollector.create(session, options=options)
        selection_prefs = SelectionPreferences(
            allow_yanked=True,
            format_control=options.format_control,
            allow_all_prereleases=options.pre,
            prefer_binary=options.prefer_binary,
            ignore_requires_python=ignore_requires_python,
        )

        return PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=selection_prefs,
            target_python=target_python,
        )