當前位置: 首頁>>代碼示例>>Python>>正文


Python download.PipSession方法代碼示例

本文整理匯總了Python中pip._internal.download.PipSession方法的典型用法代碼示例。如果您正苦於以下問題:Python download.PipSession方法的具體用法?Python download.PipSession怎麽用?Python download.PipSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip._internal.download的用法示例。


在下文中一共展示了download.PipSession方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: find_required_modules

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def find_required_modules(options, requirements_filename: str):
    explicit = set()
    for requirement in parse_requirements(requirements_filename,
                                          session=PipSession()):
        try:
            requirement_name = requirement.name
        # The type of "requirement" changed between pip versions.
        # We exclude the "except" from coverage so that on any pip version we
        # can report 100% coverage.
        except AttributeError:  # pragma: no cover
            from pip._internal.req.constructors import install_req_from_line
            requirement_name = install_req_from_line(
                requirement.requirement,
            ).name

        if options.ignore_reqs(requirement):
            log.debug('ignoring requirement: %s', requirement_name)
        else:
            log.debug('found requirement: %s', requirement_name)
            explicit.add(canonicalize_name(requirement_name))
    return explicit 
開發者ID:r1chardj0n3s,項目名稱:pip-check-reqs,代碼行數:23,代碼來源:common.py

示例2: _get_finder

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def _get_finder() -> PackageFinder:
        try:
            return PackageFinder(find_links=[], index_urls=[], session=PipSession())
        except TypeError:
            pass

        # pip 19.3
        from pip._internal.models.search_scope import SearchScope
        from pip._internal.models.selection_prefs import SelectionPreferences
        try:
            return PackageFinder.create(
                search_scope=SearchScope(find_links=[], index_urls=[]),
                selection_prefs=SelectionPreferences(allow_yanked=False),
                session=PipSession(),
            )
        except TypeError:
            pass

        from pip._internal.models.target_python import TargetPython
        try:
            # pip 19.3.1
            from pip._internal.collector import LinkCollector
        except ImportError:
            from pip._internal.index.collector import LinkCollector
        return PackageFinder.create(
            link_collector=LinkCollector(
                search_scope=SearchScope(find_links=[], index_urls=[]),
                session=PipSession(),
            ),
            selection_prefs=SelectionPreferences(allow_yanked=False),
            target_python=TargetPython(),
        )

    # https://github.com/pypa/packaging/blob/master/packaging/requirements.py
    # https://github.com/jazzband/pip-tools/blob/master/piptools/utils.py 
開發者ID:dephell,項目名稱:dephell,代碼行數:37,代碼來源:pip.py

示例3: _build_session

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def _build_session(self, options, retries=None, timeout=None):
        session = PipSession(
            cache=(
                normalize_path(os.path.join(options.cache_dir, "http"))
                if options.cache_dir else None
            ),
            retries=retries if retries is not None else options.retries,
            insecure_hosts=options.trusted_hosts,
        )

        # Handle custom ca-bundles from the user
        if options.cert:
            session.verify = options.cert

        # Handle SSL client certificate
        if options.client_cert:
            session.cert = options.client_cert

        # Handle timeouts
        if options.timeout or timeout:
            session.timeout = (
                timeout if timeout is not None else options.timeout
            )

        # Handle configured proxies
        if options.proxy:
            session.proxies = {
                "http": options.proxy,
                "https": options.proxy,
            }

        # Determine if we can prompt the user for authentication or not
        session.auth.prompting = not options.no_input

        return session 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:37,代碼來源:basecommand.py

示例4: _ensure_html_response

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def _ensure_html_response(url, session):
    # type: (str, PipSession) -> None
    """Send a HEAD request to the URL, and ensure the response contains HTML.

    Raises `_NotHTTP` if the URL is not available for a HEAD request, or
    `_NotHTML` if the content type is not text/html.
    """
    scheme, netloc, path, query, fragment = urllib_parse.urlsplit(url)
    if scheme not in {'http', 'https'}:
        raise _NotHTTP()

    resp = session.head(url, allow_redirects=True)
    resp.raise_for_status()

    _ensure_html_header(resp) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:17,代碼來源:index.py

示例5: parse_requirements

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def parse_requirements(
    filename,  # type: str
    finder=None,  # type: Optional[PackageFinder]
    comes_from=None,  # type: Optional[str]
    options=None,  # type: Optional[optparse.Values]
    session=None,  # type: Optional[PipSession]
    constraint=False,  # type: bool
    wheel_cache=None,  # type: Optional[WheelCache]
    use_pep517=None  # type: Optional[bool]
):
    # type: (...) -> Iterator[InstallRequirement]
    """Parse a requirements file and yield InstallRequirement instances.

    :param filename:    Path or url of requirements file.
    :param finder:      Instance of pip.index.PackageFinder.
    :param comes_from:  Origin description of requirements.
    :param options:     cli options.
    :param session:     Instance of pip.download.PipSession.
    :param constraint:  If true, parsing a constraint file rather than
        requirements file.
    :param wheel_cache: Instance of pip.wheel.WheelCache
    :param use_pep517:  Value of the --use-pep517 option.
    """
    if session is None:
        raise TypeError(
            "parse_requirements() missing 1 required keyword argument: "
            "'session'"
        )

    _, content = get_file_content(
        filename, comes_from=comes_from, session=session
    )

    lines_enum = preprocess(content, options)

    for line_number, line in lines_enum:
        req_iter = process_line(line, filename, line_number, finder,
                                comes_from, options, session, wheel_cache,
                                use_pep517=use_pep517, constraint=constraint)
        for req in req_iter:
            yield req 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:43,代碼來源:req_file.py

示例6: _build_session

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def _build_session(self, options, retries=None, timeout=None):
        # type: (Values, Optional[int], Optional[int]) -> PipSession
        session = PipSession(
            cache=(
                normalize_path(os.path.join(options.cache_dir, "http"))
                if options.cache_dir else None
            ),
            retries=retries if retries is not None else options.retries,
            insecure_hosts=options.trusted_hosts,
        )

        # Handle custom ca-bundles from the user
        if options.cert:
            session.verify = options.cert

        # Handle SSL client certificate
        if options.client_cert:
            session.cert = options.client_cert

        # Handle timeouts
        if options.timeout or timeout:
            session.timeout = (
                timeout if timeout is not None else options.timeout
            )

        # Handle configured proxies
        if options.proxy:
            session.proxies = {
                "http": options.proxy,
                "https": options.proxy,
            }

        # Determine if we can prompt the user for authentication or not
        session.auth.prompting = not options.no_input

        return session 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:38,代碼來源:base_command.py

示例7: _build_package_finder

# 需要導入模塊: from pip._internal import download [as 別名]
# 或者: from pip._internal.download import PipSession [as 別名]
def _build_package_finder(
        self,
        options,               # type: Values
        session,               # type: PipSession
        platform=None,         # type: Optional[str]
        python_versions=None,  # type: Optional[List[str]]
        abi=None,              # type: Optional[str]
        implementation=None    # type: Optional[str]
    ):
        # type: (...) -> PackageFinder
        """
        Create a package finder appropriate to this requirement command.
        """
        index_urls = [options.index_url] + options.extra_index_urls
        if options.no_index:
            logger.debug(
                'Ignoring indexes: %s',
                ','.join(redact_password_from_url(url) for url in index_urls),
            )
            index_urls = []

        return PackageFinder(
            find_links=options.find_links,
            format_control=options.format_control,
            index_urls=index_urls,
            trusted_hosts=options.trusted_hosts,
            allow_all_prereleases=options.pre,
            session=session,
            platform=platform,
            versions=python_versions,
            abi=abi,
            implementation=implementation,
            prefer_binary=options.prefer_binary,
        ) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:36,代碼來源:base_command.py


注:本文中的pip._internal.download.PipSession方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。