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