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


Python PipManager.get_version方法代碼示例

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


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

示例1: create_venv

# 需要導入模塊: from fades.pipmanager import PipManager [as 別名]
# 或者: from fades.pipmanager.PipManager import get_version [as 別名]
def create_venv(requested_deps, interpreter, is_current):
    """Create a new virtualvenv with the requirements of this script."""
    # create virtualenv
    env = FadesEnvBuilder()
    env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current)
    venv_data = {}
    venv_data['env_path'] = env_path
    venv_data['env_bin_path'] = env_bin_path
    venv_data['pip_installed'] = pip_installed

    # install deps
    installed = {}
    for repo in requested_deps.keys():
        if repo == REPO_PYPI:
            mgr = PipManager(env_bin_path, pip_installed=pip_installed)
        else:
            logger.warning("Install from %r not implemented", repo)
            continue
        installed[repo] = {}

        repo_requested = requested_deps[repo]
        logger.debug("Installing dependencies for repo %r: requested=%s", repo, repo_requested)
        for dependency in repo_requested:
            mgr.install(dependency)

            # always store the installed dependency, as in the future we'll select the venv
            # based on what is installed, not what used requested (remember that user may
            # request >, >=, etc!)
            project = dependency.project_name
            installed[repo][project] = mgr.get_version(project)

        logger.debug("Installed dependencies: %s", installed)
    return venv_data, installed
開發者ID:luciotorre,項目名稱:fades,代碼行數:35,代碼來源:envbuilder.py

示例2: test_get_parsing_ok

# 需要導入模塊: from fades.pipmanager import PipManager [as 別名]
# 或者: from fades.pipmanager.PipManager import get_version [as 別名]
 def test_get_parsing_ok(self):
     mocked_stdout = ['Name: foo',
                      'Version: 2.0.0',
                      'Location: ~/.local/share/fades/86cc492/lib/python3.4/site-packages',
                      'Requires: ']
     mgr = PipManager(BIN_PATH, pip_installed=True)
     with patch.object(helpers, 'logged_exec') as mock:
         mock.return_value = mocked_stdout
         version = mgr.get_version('foo')
     self.assertEqual(version, '2.0.0')
開發者ID:malderete,項目名稱:fades,代碼行數:12,代碼來源:test_pipmanager.py

示例3: test_real_case_levenshtein

# 需要導入模塊: from fades.pipmanager import PipManager [as 別名]
# 或者: from fades.pipmanager.PipManager import get_version [as 別名]
 def test_real_case_levenshtein(self):
     mocked_stdout = [
         'Metadata-Version: 1.1',
         'Name: python-Levenshtein',
         'Version: 0.12.0',
         'License: GPL',
     ]
     mgr = PipManager(BIN_PATH, pip_installed=True)
     with patch.object(helpers, 'logged_exec') as mock:
         mock.return_value = mocked_stdout
         version = mgr.get_version('foo')
     self.assertEqual(version, '0.12.0')
開發者ID:malderete,項目名稱:fades,代碼行數:14,代碼來源:test_pipmanager.py

示例4: test_get_parsing_error

# 需要導入模塊: from fades.pipmanager import PipManager [as 別名]
# 或者: from fades.pipmanager.PipManager import get_version [as 別名]
 def test_get_parsing_error(self):
     mocked_stdout = ['Name: foo',
                      'Release: 2.0.0',
                      'Location: ~/.local/share/fades/86cc492/lib/python3.4/site-packages',
                      'Requires: ']
     mgr = PipManager(BIN_PATH, pip_installed=True)
     with patch.object(helpers, 'logged_exec') as mock:
         version = mgr.get_version('foo')
         mock.return_value = mocked_stdout
     self.assertEqual(version, '')
     self.assertLoggedError('Fades is having problems getting the installed version. '
                            'Run with -v or check the logs for details')
開發者ID:malderete,項目名稱:fades,代碼行數:14,代碼來源:test_pipmanager.py

示例5: create_venv

# 需要導入模塊: from fades.pipmanager import PipManager [as 別名]
# 或者: from fades.pipmanager.PipManager import get_version [as 別名]
def create_venv(requested_deps, interpreter, is_current, options, pip_options):
    """Create a new virtualvenv with the requirements of this script."""
    # create virtualenv
    env = _FadesEnvBuilder()
    env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options)
    venv_data = {}
    venv_data['env_path'] = env_path
    venv_data['env_bin_path'] = env_bin_path
    venv_data['pip_installed'] = pip_installed

    # install deps
    installed = {}
    for repo in requested_deps.keys():
        if repo in (REPO_PYPI, REPO_VCS):
            mgr = PipManager(env_bin_path, pip_installed=pip_installed, options=pip_options)
        else:
            logger.warning("Install from %r not implemented", repo)
            continue
        installed[repo] = {}

        repo_requested = requested_deps[repo]
        logger.debug("Installing dependencies for repo %r: requested=%s", repo, repo_requested)
        for dependency in repo_requested:
            try:
                mgr.install(dependency)
            except Exception:
                logger.debug("Installation Step failed, removing virtualenv")
                destroy_venv(env_path)
                raise FadesError('Dependency installation failed')

            if repo == REPO_VCS:
                # no need to request the installed version, as we'll always compare
                # to the url itself
                project = dependency.url
                version = None
            else:
                # always store the installed dependency, as in the future we'll select the venv
                # based on what is installed, not what used requested (remember that user may
                # request >, >=, etc!)
                project = dependency.project_name
                version = mgr.get_version(project)
            installed[repo][project] = version

        logger.debug("Installed dependencies: %s", installed)
    return venv_data, installed
開發者ID:PyAr,項目名稱:fades,代碼行數:47,代碼來源:envbuilder.py


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