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


Python pkg_resources.RequirementParseError方法代码示例

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


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

示例1: get_raw_requirements

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def get_raw_requirements(filename):
    ret = []
    for line in get_lines_from_file(filename):
        # allow something to editably install itself
        if line.strip() == '-e .':
            continue
        try:
            ret.append((parse_requirement(line), filename))
        except pkg_resources.RequirementParseError as e:
            raise AssertionError(
                'Requirements must be <<pkg>> or <<pkg>>==<<version>>\n'
                ' - git / http / etc. urls may be mutable (unpinnable)\n'
                ' - transitive dependencies from urls are not traceable\n'
                ' - line of error: {}\n'
                ' - inner exception: {!r}\n'.format(line.strip(), e),
            )
    return ret 
开发者ID:Yelp,项目名称:requirements-tools,代码行数:19,代码来源:check_requirements.py

示例2: _get_cached_requirements

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def _get_cached_requirements(self):
        import os.path
        import pkg_resources

        path = os.path.join(self._cache_dir, 'requirements.txt')

        if not os.path.exists(path):
            # No cached requirements. The empty set will always trigger a cache
            # refresh because the current requirements will, at minimum,
            # contain q2cli.
            return set()
        else:
            with open(path, 'r') as fh:
                contents = fh.read()
            try:
                return set(pkg_resources.parse_requirements(contents))
            except pkg_resources.RequirementParseError:
                # Unreadable cached requirements, trigger a cache refresh.
                return set() 
开发者ID:qiime2,项目名称:q2cli,代码行数:21,代码来源:cache.py

示例3: version_info

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def version_info(module):
    """Get version of a standard python module.

    Args:
        module (module): python module object to get version info for.

    Returns:
        dict: dictionary of version info.

    """
    if hasattr(module, '__version__'):
        version = module.__version__
    elif hasattr(module, 'VERSION'):
        version = module.VERSION
    else:
        pkgname = module.__name__.split('.')[0]
        try:
            info = pkg_resources.get_distribution(pkgname)
        except (pkg_resources.DistributionNotFound, pkg_resources.RequirementParseError):
            version = None
            log.warning(
                'version information not found for %s -- what package is this from?' % module.__name__)
        else:
            version = info.version

    return {'version': version} 
开发者ID:neuroailab,项目名称:tfutils,代码行数:28,代码来源:db_interface.py

示例4: check_requirements

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def check_requirements():
    """Make sure all listed packages from requirements.txt have been installed into the virtualenv at boot.
    """
    if not os.path.exists(REQUIREMENTS):
        sys.exit(
            ansi.error() + ' %s is missing. Please check it in.' % ansi.underline(REQUIREMENTS)
        )

    with open(REQUIREMENTS, 'r', encoding='utf-8') as f:
        dependencies = f.readlines()

    vcs = [d for d in dependencies if re.match(r'^(-e )?(git|svn|hg|bzr).*', d)]

    dependencies = list(set(dependencies) - set(vcs))

    missing = []
    try:
        pkg_resources.require(dependencies)
    except (
        pkg_resources.ContextualVersionConflict,
        pkg_resources.DistributionNotFound,
        pkg_resources.VersionConflict
    ) as error:
        missing.append(str(error))
    except pkg_resources.RequirementParseError:
        pass

    if missing:
        missing = ' missing requirement:\n  ' + os.linesep.join(missing)
        if '--env-checked' in sys.argv:
            sys.exit(ansi.error() + missing + '\nRequirement installation failure, please check for errors in:\n $ lore install\n')
        else:
            print(ansi.warning() + missing)
            import lore.__main__
            lore.__main__.install_requirements(None)
            reboot('--env-checked') 
开发者ID:instacart,项目名称:lore,代码行数:38,代码来源:env.py

示例5: try_parse_requirements

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def try_parse_requirements(lines: typed_list(str)):
        """
        Yields all package requirements parsable from the given lines.

        :param lines: An iterable of lines from a requirements file.
        """
        for line in lines:
            try:
                yield from pkg_resources.parse_requirements(line)
            except pkg_resources.RequirementParseError:
                # unsupported requirement specification
                pass 
开发者ID:coala,项目名称:coala-bears,代码行数:14,代码来源:PySafetyBear.py

示例6: find_python_interpreter

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def find_python_interpreter(version_spec):
    import pkg_resources

    try:
        # Requirement.parse wants a package name, so we use 'python'
        # here, but anything would do.
        req = pkg_resources.Requirement.parse("python%s" % version_spec)
    except pkg_resources.RequirementParseError:
        raise ValueError(version_spec)
    python_interps = {ver: path for path, ver in python_interpreters()}
    matching = list(req.specifier.filter(sorted(python_interps)))
    if matching:
        matching_ver = matching[0]
        return python_interps[matching_ver], matching_ver
    return None 
开发者ID:guildai,项目名称:guildai,代码行数:17,代码来源:util.py

示例7: requirements_list_from_file

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import RequirementParseError [as 别名]
def requirements_list_from_file(requirements_file, dependency_links):
    """
    Parse a requirements file.

    Requirements that have an environment marker will only be included
    in the list if the marker evaluates True.

    ``--find-links`` lines will be added to the supplied ``dependency_links``
    list.

    XXX There's a package called ``pbr`` which is also supposed to do this
    job. I couldn't get it to work --RichardW.
    """
    requirements = []
    with open(requirements_file) as f:
        for line in f:
            line = line.rstrip()
            if line.startswith('#'):
                continue
            elif line.startswith('--find-links'):
                link = line.split(None, 1)[1]
                dependency_links.append(link)
            else:
                parsed_requirements = parse_requirements(line)
                try:
                    (req,) = list(parsed_requirements)
                except RequirementParseError as original_error:
                    # XXX Buildbot has an old version of setuptools /
                    # pkg_resources which can't parse environment markers.
                    message = unicode(original_error)
                    if environ['HOME'] != "/srv/buildslave":
                        raise
                    if not message.startswith("Expected version spec in "):
                        raise
                    if ";" not in line:
                        raise
                    continue
                if getattr(req, "marker", None) and not req.marker.evaluate():
                    continue
                requirements.append(unicode(req))
    return requirements

# Parse the ``.in`` files. This will allow the dependencies to float when
# Flocker is installed using ``pip install .``.
# It also allows Flocker to be imported as a package alongside other Python
# libraries that may require different versions than those specified in
# Flocker's pinned dependency files. 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:49,代码来源:setup.py


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