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


Python pip.req方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import req [as 別名]
def __init__(self, req, argv, finder):
        """Download a requirement, compare its hashes, and return a subclass
        of DownloadedReq depending on its state.

        :arg req: The InstallRequirement I am based on
        :arg argv: The args, starting after the subcommand

        """
        self._req = req
        self._argv = argv
        self._finder = finder

        # We use a separate temp dir for each requirement so requirements
        # (from different indices) that happen to have the same archive names
        # don't overwrite each other, leading to a security hole in which the
        # latter is a hash mismatch, the former has already passed the
        # comparison, and the latter gets installed.
        self._temp_path = mkdtemp(prefix='peep-')
        # Think of DownloadedReq as a one-shot state machine. It's an abstract
        # class that ratchets forward to being one of its own subclasses,
        # depending on its package status. Then it doesn't move again.
        self.__class__ = self._class() 
開發者ID:mozilla,項目名稱:feedthefox,代碼行數:24,代碼來源:peep.py

示例2: downloaded_reqs_from_path

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

示例3: merge_source_requirements

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import req [as 別名]
def merge_source_requirements(sources):
    """
    Read requirements source files and merge it's content.
    """
    projects = set()
    merged_requirements = []
    for infile_path in (locate_file(p, must_exist=True) for p in sources):
        for req in load_requirements(infile_path):
            # Requirements starting with project name "project ..."
            if req.req:
                # Skip already added project name
                if req.name in projects:
                    continue
                projects.add(req.name)
                merged_requirements.append(req)

            # Requirements lines like "vcs+proto://url"
            elif req.link:
                merged_requirements.append(req)
            else:
                raise RuntimeError('Unexpected requirement {0}'.format(req))

    return merged_requirements 
開發者ID:StackStorm,項目名稱:st2,代碼行數:25,代碼來源:fixate-requirements.py

示例4: run

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

示例5: _project_name

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import req [as 別名]
def _project_name(self):
        """Return the inner Requirement's "unsafe name".

        Raise ValueError if there is no name.

        """
        name = getattr(self._req.req, 'project_name', '')
        if name:
            return name
        raise ValueError('Requirement has no project_name.') 
開發者ID:mozilla,項目名稱:feedthefox,代碼行數:12,代碼來源:peep.py

示例6: get_requirements

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

示例7: fetch_requirements

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import req [as 別名]
def fetch_requirements(requirements_file_path):
    """
    Return a list of requirements and links by parsing the provided requirements file.
    """
    links = []
    reqs = []
    for req in parse_requirements(requirements_file_path, session=False):
        # Note: req.url was used before 9.0.0 and req.link is used in all the recent versions
        link = getattr(req, 'link', getattr(req, 'url', None))
        if link:
            links.append(str(link))
        reqs.append(str(req.req))
    return (reqs, links) 
開發者ID:StackStorm,項目名稱:st2,代碼行數:15,代碼來源:dist_utils_old.py

示例8: get_install_requirements

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import req [as 別名]
def get_install_requirements(path):
    content = open(os.path.join(os.path.dirname(__file__), path)).read()
    return [
        req
        for req in content.split("\n")
        if req != '' and not req.startswith('#')
    ]

# Get version from __init__.py file 
開發者ID:bryanyang0528,項目名稱:ksql-python,代碼行數:11,代碼來源:setup.py

示例9: __init__

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import req [as 別名]
def __init__(self, req):
            self.req = req 
開發者ID:Nekmo,項目名稱:simple-monitor-alert,代碼行數:4,代碼來源:setup.py


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