當前位置: 首頁>>代碼示例>>Python>>正文


Python req.parse_requirements方法代碼示例

本文整理匯總了Python中pip.req.parse_requirements方法的典型用法代碼示例。如果您正苦於以下問題:Python req.parse_requirements方法的具體用法?Python req.parse_requirements怎麽用?Python req.parse_requirements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip.req的用法示例。


在下文中一共展示了req.parse_requirements方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def run(self, options, args):
        session = self._build_session(options)

        requirement_set = RequirementSet(
            build_dir=None,
            src_dir=None,
            download_dir=None,
            session=session,
        )
        for name in args:
            requirement_set.add_requirement(
                InstallRequirement.from_line(name))
        for filename in options.requirements:
            for req in parse_requirements(filename,
                    options=options, session=session):
                requirement_set.add_requirement(req)
        if not requirement_set.has_requirements:
            raise InstallationError('You must give at least one requirement '
                'to %(name)s (see "pip help %(name)s")' % dict(name=self.name))
        requirement_set.uninstall(auto_confirm=options.yes) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:22,代碼來源:uninstall.py

示例2: read_requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.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

示例3: downloaded_reqs_from_path

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def downloaded_reqs_from_path(path, argv):
    """Return a list of DownloadedReqs representing the requirements parsed
    out of a given requirements file.

    :arg path: The path to the requirements file
    :arg argv: The commandline args, starting after the subcommand

    """
    finder = package_finder(argv)

    def downloaded_reqs(parsed_reqs):
        """Just avoid repeating this list comp."""
        return [DownloadedReq(req, argv, finder) for req in parsed_reqs]

    try:
        return downloaded_reqs(parse_requirements(
            path, options=EmptyOptions(), finder=finder))
    except TypeError:
        # session is a required kwarg as of pip 6.0 and will raise
        # a TypeError if missing. It needs to be a PipSession instance,
        # but in older versions we can't import it from pip.download
        # (nor do we need it at all) so we only import it in this except block
        from pip.download import PipSession
        return downloaded_reqs(parse_requirements(
            path, options=EmptyOptions(), session=PipSession(), finder=finder)) 
開發者ID:mozilla,項目名稱:feedthefox,代碼行數:27,代碼來源:peep.py

示例4: find_python_pip

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.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

示例5: get_requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.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

示例6: run

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def run(self, options, args):
        with self._build_session(options) as session:
            format_control = pip.index.FormatControl(set(), set())
            wheel_cache = WheelCache(options.cache_dir, format_control)
            requirement_set = RequirementSet(
                build_dir=None,
                src_dir=None,
                download_dir=None,
                isolated=options.isolated_mode,
                session=session,
                wheel_cache=wheel_cache,
            )
            for name in args:
                requirement_set.add_requirement(
                    InstallRequirement.from_line(
                        name, isolated=options.isolated_mode,
                        wheel_cache=wheel_cache
                    )
                )
            for filename in options.requirements:
                for req in parse_requirements(
                        filename,
                        options=options,
                        session=session,
                        wheel_cache=wheel_cache):
                    requirement_set.add_requirement(req)
            if not requirement_set.has_requirements:
                raise InstallationError(
                    'You must give at least one requirement to %(name)s (see '
                    '"pip help %(name)s")' % dict(name=self.name)
                )
            requirement_set.uninstall(auto_confirm=options.yes) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:34,代碼來源:uninstall.py

示例7: get_requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.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

示例8: execute_setup

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def execute_setup():
  """
  Setup function
  """
  if sys.version_info < (2, 0) or sys.version_info >= (3, 0):
    sys.exit("i3-xfce only supports python2. Please run setup.py with python2.")

  install_reqs = parse_requirements("requirements.txt", session=False)
  requirements = [str(ir.req) for ir in install_reqs]
  
  setup(
      name="i3-xfce",
      version=versioneer.get_version(),
      cmdclass=versioneer.get_cmdclass(),
      packages=find_packages("src"),
      package_dir={'':'src'},
      include_package_data=True,
      install_requires=requirements,
      author="Alexandre ACEBEDO",
      author_email="Alexandre ACEBEDO",
      description="I3 installer for xfce4",
      license="LGPLv3",
      keywords="i3 xfce",
      url="http://github.com/aacebedo/i3-xfce",
      entry_points={'console_scripts':
                    ['i3-xfce = i3xfce.core:main']}
      ) 
開發者ID:aacebedo,項目名稱:i3-xfce,代碼行數:29,代碼來源:setup.py

示例9: test_PipVCSInstallRequirement

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def test_PipVCSInstallRequirement(self):
        requirements_str = """
        git+https://github.com/foo/bar
        git+https://code.google.com/p/foo
        git+git://code.google.com/p/foo#egg=bar
        """
        expected = [
            {
                'type': 'vcs',
                'key': 'https://github.com/foo/bar',
                'repo_url': 'https://github.com/foo/bar',
                'unsafe_name': None, 'extras': None, 'modules': None, 'packages': None, 'project_name': None,
                'resolved': False, 'specs': None,
            },
            {
                'type': 'vcs',
                'key': 'https://code.google.com/p/foo',
                'repo_url': 'https://code.google.com/p/foo',
                'unsafe_name': None, 'extras': None, 'modules': None, 'packages': None, 'project_name': None,
                'resolved': False, 'specs': None,
            },
            {
                'type': 'vcs',
                'key': 'bar(git://code.google.com/p/foo)',
                'repo_url': 'git://code.google.com/p/foo',
                'unsafe_name': 'bar',
                'project_name': 'bar',
                'specs': [], 'extras': (), 'modules': None, 'packages': None, 'resolved': False,
            },
        ]

        handle, requirements_file = tempfile.mkstemp()
        with open(requirements_file, 'w') as f:
            f.write(requirements_str)

        pip_reqs = req.parse_requirements(requirements_file, session=pip.download.PipSession())
        reqs = [PipURLInstallRequirement(r).to_dict() for r in pip_reqs]
        os.fdopen(handle).close()
        os.remove(requirements_file)

        self.assertListEqual(expected, reqs) 
開發者ID:sourcegraph,項目名稱:pydep,代碼行數:43,代碼來源:req_test.py

示例10: _requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.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

示例11: requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.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

示例12: requirements_from_file

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def requirements_from_file(filename):
    requirements = []
    for r in parse_requirements(filename, session='fake'):
        if r.match_markers():
            requirements.append(str(r.req))
    return requirements 
開發者ID:bayandin,項目名稱:devtools-proxy,代碼行數:8,代碼來源:setup.py

示例13: get_requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def get_requirements():
    reqs = parse_requirements('requirements.txt')
    return [str(current.req) for current in reqs] 
開發者ID:ovh,項目名稱:ip-reputation-monitoring,代碼行數:5,代碼來源:setup.py

示例14: get_requirements

# 需要導入模塊: from pip import req [as 別名]
# 或者: from pip.req import parse_requirements [as 別名]
def get_requirements(cls, file='requirements.txt'):
        from pip.req import parse_requirements
        return list(parse_requirements(file))


# Setup initial loggers 
開發者ID:helionmusic,項目名稱:rhinobot_heroku,代碼行數:8,代碼來源:run.py


注:本文中的pip.req.parse_requirements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。