当前位置: 首页>>代码示例>>Python>>正文


Python requirements.InvalidRequirement方法代码示例

本文整理汇总了Python中pip._vendor.packaging.requirements.InvalidRequirement方法的典型用法代码示例。如果您正苦于以下问题:Python requirements.InvalidRequirement方法的具体用法?Python requirements.InvalidRequirement怎么用?Python requirements.InvalidRequirement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.packaging.requirements的用法示例。


在下文中一共展示了requirements.InvalidRequirement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_req_from_editable

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def parse_req_from_editable(editable_req):
    # type: (str) -> RequirementParts
    name, url, extras_override = parse_editable(editable_req)

    if name is not None:
        try:
            req = Requirement(name)
        except InvalidRequirement:
            raise InstallationError("Invalid requirement: '%s'" % name)
    else:
        req = None

    link = Link(url)

    return RequirementParts(req, link, None, extras_override)


# ---- The actual constructors follow ---- 
开发者ID:pantsbuild,项目名称:pex,代码行数:20,代码来源:constructors.py

示例2: install_req_from_req

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def install_req_from_req(
    req, comes_from=None, isolated=False, wheel_cache=None
):
    try:
        req = Requirement(req)
    except InvalidRequirement:
        raise InstallationError("Invalid requirement: '%s'" % req)

    domains_not_allowed = [
        PyPI.file_storage_domain,
        TestPyPI.file_storage_domain,
    ]
    if req.url and comes_from.link.netloc in domains_not_allowed:
        # Explicitly disallow pypi packages that depend on external urls
        raise InstallationError(
            "Packages installed from PyPI cannot depend on packages "
            "which are not also hosted on PyPI.\n"
            "%s depends on %s " % (comes_from.name, req)
        )

    return InstallRequirement(
        req, comes_from, isolated=isolated, wheel_cache=wheel_cache
    ) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:25,代码来源:constructors.py

示例3: parse_req_from_editable

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def parse_req_from_editable(editable_req):
    # type: (str) -> RequirementParts
    name, url, extras_override = parse_editable(editable_req)

    if name is not None:
        try:
            req = Requirement(name)
        except InvalidRequirement:
            raise InstallationError("Invalid requirement: '{}'".format(name))
    else:
        req = None

    link = Link(url)

    return RequirementParts(req, link, None, extras_override)


# ---- The actual constructors follow ---- 
开发者ID:ali5h,项目名称:rules_pip,代码行数:20,代码来源:constructors.py

示例4: from_editable

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def from_editable(cls, editable_req, comes_from=None, isolated=False,
                      options=None, wheel_cache=None, constraint=False):
        from pip._internal.index import Link

        name, url, extras_override = parse_editable(editable_req)
        if url.startswith('file:'):
            source_dir = url_to_path(url)
        else:
            source_dir = None

        if name is not None:
            try:
                req = Requirement(name)
            except InvalidRequirement:
                raise InstallationError("Invalid requirement: '%s'" % name)
        else:
            req = None
        return cls(
            req, comes_from, source_dir=source_dir,
            editable=True,
            link=Link(url),
            constraint=constraint,
            isolated=isolated,
            options=options if options else {},
            wheel_cache=wheel_cache,
            extras=extras_override or (),
        ) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:29,代码来源:req_install.py

示例5: from_req

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def from_req(cls, req, comes_from=None, isolated=False, wheel_cache=None):
        try:
            req = Requirement(req)
        except InvalidRequirement:
            raise InstallationError("Invalid requirement: '%s'" % req)
        if req.url:
            raise InstallationError(
                "Direct url requirement (like %s) are not allowed for "
                "dependencies" % req
            )
        return cls(req, comes_from, isolated=isolated, wheel_cache=wheel_cache) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:13,代码来源:req_install.py

示例6: install_req_from_editable

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def install_req_from_editable(
    editable_req,  # type: str
    comes_from=None,  # type: Optional[str]
    use_pep517=None,  # type: Optional[bool]
    isolated=False,  # type: bool
    options=None,  # type: Optional[Dict[str, Any]]
    wheel_cache=None,  # type: Optional[WheelCache]
    constraint=False  # type: bool
):
    # type: (...) -> InstallRequirement
    name, url, extras_override = parse_editable(editable_req)
    if url.startswith('file:'):
        source_dir = url_to_path(url)
    else:
        source_dir = None

    if name is not None:
        try:
            req = Requirement(name)
        except InvalidRequirement:
            raise InstallationError("Invalid requirement: '%s'" % name)
    else:
        req = None
    return InstallRequirement(
        req, comes_from, source_dir=source_dir,
        editable=True,
        link=Link(url),
        constraint=constraint,
        use_pep517=use_pep517,
        isolated=isolated,
        options=options if options else {},
        wheel_cache=wheel_cache,
        extras=extras_override or (),
    ) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:36,代码来源:constructors.py

示例7: install_req_from_req_string

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def install_req_from_req_string(
    req_string,  # type: str
    comes_from=None,  # type: Optional[InstallRequirement]
    isolated=False,  # type: bool
    wheel_cache=None,  # type: Optional[WheelCache]
    use_pep517=None  # type: Optional[bool]
):
    # type: (...) -> InstallRequirement
    try:
        req = Requirement(req_string)
    except InvalidRequirement:
        raise InstallationError("Invalid requirement: '%s'" % req_string)

    domains_not_allowed = [
        PyPI.file_storage_domain,
        TestPyPI.file_storage_domain,
    ]
    if (req.url and comes_from and comes_from.link and
            comes_from.link.netloc in domains_not_allowed):
        # Explicitly disallow pypi packages that depend on external urls
        raise InstallationError(
            "Packages installed from PyPI cannot depend on packages "
            "which are not also hosted on PyPI.\n"
            "%s depends on %s " % (comes_from.name, req)
        )

    return InstallRequirement(
        req, comes_from, isolated=isolated, wheel_cache=wheel_cache,
        use_pep517=use_pep517
    ) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:32,代码来源:constructors.py

示例8: install_req_from_req_string

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def install_req_from_req_string(
    req_string,  # type: str
    comes_from=None,  # type: Optional[InstallRequirement]
    isolated=False,  # type: bool
    wheel_cache=None,  # type: Optional[WheelCache]
    use_pep517=None  # type: Optional[bool]
):
    # type: (...) -> InstallRequirement
    try:
        req = Requirement(req_string)
    except InvalidRequirement:
        raise InstallationError("Invalid requirement: '%s'" % req)

    domains_not_allowed = [
        PyPI.file_storage_domain,
        TestPyPI.file_storage_domain,
    ]
    if req.url and comes_from.link.netloc in domains_not_allowed:
        # Explicitly disallow pypi packages that depend on external urls
        raise InstallationError(
            "Packages installed from PyPI cannot depend on packages "
            "which are not also hosted on PyPI.\n"
            "%s depends on %s " % (comes_from.name, req)
        )

    return InstallRequirement(
        req, comes_from, isolated=isolated, wheel_cache=wheel_cache,
        use_pep517=use_pep517
    ) 
开发者ID:QData,项目名称:deepWordBug,代码行数:31,代码来源:constructors.py

示例9: install_req_from_editable

# 需要导入模块: from pip._vendor.packaging import requirements [as 别名]
# 或者: from pip._vendor.packaging.requirements import InvalidRequirement [as 别名]
def install_req_from_editable(
    editable_req, comes_from=None, isolated=False, options=None,
    wheel_cache=None, constraint=False
):
    name, url, extras_override = parse_editable(editable_req)
    if url.startswith('file:'):
        source_dir = url_to_path(url)
    else:
        source_dir = None

    if name is not None:
        try:
            req = Requirement(name)
        except InvalidRequirement:
            raise InstallationError("Invalid requirement: '%s'" % name)
    else:
        req = None
    return InstallRequirement(
        req, comes_from, source_dir=source_dir,
        editable=True,
        link=Link(url),
        constraint=constraint,
        isolated=isolated,
        options=options if options else {},
        wheel_cache=wheel_cache,
        extras=extras_override or (),
    ) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:29,代码来源:constructors.py


注:本文中的pip._vendor.packaging.requirements.InvalidRequirement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。