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


Python req.parse_requirements方法代码示例

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


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

示例1: read_requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def read_requirements(req_file):
    """Reads a requirements file.

    Args:
        req_file (str): Filename of requirements file
    """
    items = list(parse_requirements(req_file, session={}))
    result = []

    for item in items:
        # Get line number from item
        line_number = item.comes_from.split(req_file + ' (line ')[1][:-1]
        if item.req:
            item.req.marker = item.markers
            result.append((item.req, line_number))
        else:
            result.append((item, line_number))

    return result 
开发者ID:GoogleCloudPlatform,项目名称:python-repo-tools,代码行数:21,代码来源:requirements.py

示例2: find_python_pip

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def find_python_pip(self, file_path):
        for requirement in file_path:
            if 'requirements.txt' in requirement:
                reqs = parse_requirements(filename=requirement, session=False)
                for r in reqs:
                    module_ = r.name
                    version_ = r.specifier
                    self._framework.append(module_)
                    self._result.update(
                        {
                            module_: {
                                'version': str(version_),
                                'format': 'python',
                            }
                        }
                    )
            elif 'package.json' in requirement:
                self.find_nodejs_npm([requirement]) 
开发者ID:WhaleShark-Team,项目名称:cobra,代码行数:20,代码来源:dependencies.py

示例3: get_requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def get_requirements(requirements_file):
    """Use pip to parse requirements file."""
    requirements = []
    if path.isfile(requirements_file):
        for req in parse_requirements(requirements_file, session="hack"):
            try:
                # check markers, such as
                #
                #     rope_py3k    ; python_version >= '3.0'
                #
                if req.match_markers():
                    requirements.append(str(req.req))
            except AttributeError:
                # pip >= 20.0.2
                requirements.append(req.requirement)
    return requirements 
开发者ID:modoboa,项目名称:modoboa-amavis,代码行数:18,代码来源:setup.py

示例4: get_requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def get_requirements(filename=None):
    """
    Read requirements from 'requirements.txt'

    :return: requirements
    :rtype: list
    """
    if filename is None:
        filename = 'requirements.txt'

    file = WORK_DIR / filename

    install_reqs = parse_requirements(str(file), session='hack')
    return [str(ir.req) for ir in install_reqs] 
开发者ID:mahenzon,项目名称:aioalice,代码行数:16,代码来源:setup.py

示例5: run

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def run(self, options, args):
        with self._build_session(options) as session:
            reqs_to_uninstall = {}
            for name in args:
                req = InstallRequirement.from_line(
                    name, isolated=options.isolated_mode,
                )
                if req.name:
                    reqs_to_uninstall[canonicalize_name(req.name)] = req
            for filename in options.requirements:
                for req in parse_requirements(
                        filename,
                        options=options,
                        session=session):
                    if req.name:
                        reqs_to_uninstall[canonicalize_name(req.name)] = req
            if not reqs_to_uninstall:
                raise InstallationError(
                    'You must give at least one requirement to %(name)s (see '
                    '"pip help %(name)s")' % dict(name=self.name)
                )
            for req in reqs_to_uninstall.values():
                uninstall_pathset = req.uninstall(
                    auto_confirm=options.yes, verbose=self.verbosity > 0,
                )
                if uninstall_pathset:
                    uninstall_pathset.commit() 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:29,代码来源:uninstall.py

示例6: run

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def run(self, options, args):
        with self._build_session(options) as session:
            reqs_to_uninstall = {}
            for name in args:
                req = install_req_from_line(
                    name, isolated=options.isolated_mode,
                )
                if req.name:
                    reqs_to_uninstall[canonicalize_name(req.name)] = req
            for filename in options.requirements:
                for req in parse_requirements(
                        filename,
                        options=options,
                        session=session):
                    if req.name:
                        reqs_to_uninstall[canonicalize_name(req.name)] = req
            if not reqs_to_uninstall:
                raise InstallationError(
                    'You must give at least one requirement to %(name)s (see '
                    '"pip help %(name)s")' % dict(name=self.name)
                )

            protect_pip_from_modification_on_windows(
                modifying_pip="pip" in reqs_to_uninstall
            )

            for req in reqs_to_uninstall.values():
                uninstall_pathset = req.uninstall(
                    auto_confirm=options.yes, verbose=self.verbosity > 0,
                )
                if uninstall_pathset:
                    uninstall_pathset.commit() 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:34,代码来源:uninstall.py

示例7: run

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def run(self, options, args):
        session = self.get_default_session(options)

        reqs_to_uninstall = {}
        for name in args:
            req = install_req_from_line(
                name, isolated=options.isolated_mode,
            )
            if req.name:
                reqs_to_uninstall[canonicalize_name(req.name)] = req
        for filename in options.requirements:
            for req in parse_requirements(
                    filename,
                    options=options,
                    session=session):
                if req.name:
                    reqs_to_uninstall[canonicalize_name(req.name)] = req
        if not reqs_to_uninstall:
            raise InstallationError(
                'You must give at least one requirement to %(name)s (see '
                '"pip help %(name)s")' % dict(name=self.name)
            )

        protect_pip_from_modification_on_windows(
            modifying_pip="pip" in reqs_to_uninstall
        )

        for req in reqs_to_uninstall.values():
            uninstall_pathset = req.uninstall(
                auto_confirm=options.yes, verbose=self.verbosity > 0,
            )
            if uninstall_pathset:
                uninstall_pathset.commit() 
开发者ID:pantsbuild,项目名称:pex,代码行数:35,代码来源:uninstall.py

示例8: _requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def _requirements(self):
        requirements_txt = os.path.join(self.target_directory, 'requirements.txt')
        logger.debug(requirements_txt)
        if os.path.isfile(requirements_txt):
            requirements = parse_requirements(requirements_txt, session=False)
            self.requirements = [req.name.strip().lower() for req in requirements]
            logger.debug('requirements modules count: {count} ({modules})'.format(count=len(self.requirements),
                                                                                  modules=','.join(self.requirements)))
        else:
            logger.debug('requirements.txt not found!')
            self.requirements = [] 
开发者ID:LoRexxar,项目名称:Cobra-W,代码行数:13,代码来源:detection.py

示例9: run

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def run(self, options, args):
        with self._build_session(options) as session:
            reqs_to_uninstall = {}
            for name in args:
                req = InstallRequirement.from_line(
                    name, isolated=options.isolated_mode,
                )
                if req.name:
                    reqs_to_uninstall[canonicalize_name(req.name)] = req
            for filename in options.requirements:
                for req in parse_requirements(
                        filename,
                        options=options,
                        session=session):
                    if req.name:
                        reqs_to_uninstall[canonicalize_name(req.name)] = req
            if not reqs_to_uninstall:
                raise InstallationError(
                    'You must give at least one requirement to %(name)s (see '
                    '"pip help %(name)s")' % dict(name=self.name)
                )

            protect_pip_from_modification_on_windows(
                modifying_pip="pip" in reqs_to_uninstall
            )

            for req in reqs_to_uninstall.values():
                uninstall_pathset = req.uninstall(
                    auto_confirm=options.yes, verbose=self.verbosity > 0,
                )
                if uninstall_pathset:
                    uninstall_pathset.commit() 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:34,代码来源:uninstall.py

示例10: requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def requirements(filename):
    reqs = parse_requirements(filename, session=False)
    return [str(r.req) for r in reqs] 
开发者ID:wizeline,项目名称:sqlalchemy-pagination,代码行数:5,代码来源:setup.py

示例11: run

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def run(self, options, args):
        session = self.get_default_session(options)

        reqs_to_uninstall = {}
        for name in args:
            req = install_req_from_line(
                name, isolated=options.isolated_mode,
            )
            if req.name:
                reqs_to_uninstall[canonicalize_name(req.name)] = req
        for filename in options.requirements:
            for parsed_req in parse_requirements(
                    filename,
                    options=options,
                    session=session):
                req = install_req_from_parsed_requirement(
                    parsed_req,
                    isolated=options.isolated_mode
                )
                if req.name:
                    reqs_to_uninstall[canonicalize_name(req.name)] = req
        if not reqs_to_uninstall:
            raise InstallationError(
                'You must give at least one requirement to {self.name} (see '
                '"pip help {self.name}")'.format(**locals())
            )

        protect_pip_from_modification_on_windows(
            modifying_pip="pip" in reqs_to_uninstall
        )

        for req in reqs_to_uninstall.values():
            uninstall_pathset = req.uninstall(
                auto_confirm=options.yes, verbose=self.verbosity > 0,
            )
            if uninstall_pathset:
                uninstall_pathset.commit() 
开发者ID:ali5h,项目名称:rules_pip,代码行数:39,代码来源:uninstall.py

示例12: parse_requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def parse_requirements(
    filename, session, finder=None, options=None, constraint=False, isolated=False
):
    for parsed_req in _parse_requirements(
        filename, session, finder=finder, options=options, constraint=constraint
    ):
        yield install_req_from_parsed_requirement(parsed_req, isolated=isolated) 
开发者ID:ali5h,项目名称:rules_pip,代码行数:9,代码来源:pip_compat.py

示例13: install_requires

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def install_requires():
    file = WORK_DIR / "requirements.txt"
    install_reqs = parse_requirements(str(file), session='sync')
    return [str(ir.req) for ir in install_reqs] 
开发者ID:dyseo,项目名称:AsyncLine,代码行数:6,代码来源:setup.py

示例14: load_requirements

# 需要导入模块: from pip._internal import req [as 别名]
# 或者: from pip._internal.req import parse_requirements [as 别名]
def load_requirements(fname):
    reqs = parse_requirements(fname, session="test")
    return [str(ir.req) for ir in reqs] 
开发者ID:GNSSpy-Project,项目名称:gnsspy,代码行数:5,代码来源:setup.py


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