當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。