本文整理汇总了Python中fades.pipmanager.PipManager.install方法的典型用法代码示例。如果您正苦于以下问题:Python PipManager.install方法的具体用法?Python PipManager.install怎么用?Python PipManager.install使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fades.pipmanager.PipManager
的用法示例。
在下文中一共展示了PipManager.install方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_install_raise_error
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install_raise_error(self):
mgr = PipManager(BIN_PATH, pip_installed=True)
with patch.object(helpers, 'logged_exec') as mock:
mock.side_effect = Exception("Kapow!")
with self.assertRaises(Exception):
mgr.install('foo')
self.assertLoggedError("Error installing foo: Kapow!")
示例2: create_venv
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [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
示例3: test_install_without_pip
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install_without_pip(self):
mgr = PipManager('/usr/bin', pip_installed=False)
with patch.object(helpers, 'logged_exec') as mocked_exec:
with patch.object(mgr, '_brute_force_install_pip') as mocked_install_pip:
mgr.install('foo')
self.assertEqual(mocked_install_pip.call_count, 1)
mocked_exec.assert_called_with(['/usr/bin/pip', 'install', 'foo'])
示例4: test_say_hi_on_first_install
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_say_hi_on_first_install(self):
mgr = PipManager(BIN_PATH, pip_installed=True, options=['--bar=baz'])
with patch.object(helpers, 'logged_exec'):
mgr.install('foo')
self.assertLoggedInfo("Hi! This is fades")
logassert.setup(self, 'fades.pipmanager')
mgr.install('bar')
self.assertNotLoggedInfo("Hi! This is fades")
示例5: test_install_without_pip
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install_without_pip(self):
mgr = PipManager(BIN_PATH, pip_installed=False)
pip_path = os.path.join(BIN_PATH, 'pip')
with patch.object(helpers, 'logged_exec') as mocked_exec:
with patch.object(mgr, '_brute_force_install_pip') as mocked_install_pip:
mgr.install('foo')
self.assertEqual(mocked_install_pip.call_count, 1)
mocked_exec.assert_called_with([pip_path, 'install', 'foo'])
示例6: create_venv
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [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
示例7: test_install_with_options_using_equal
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install_with_options_using_equal(self):
mgr = PipManager(BIN_PATH, pip_installed=True, options=['--bar=baz'])
pip_path = os.path.join(BIN_PATH, 'pip')
with patch.object(helpers, 'logged_exec') as mock:
mgr.install('foo')
mock.assert_called_with([pip_path, 'install', 'foo', '--bar=baz'])
示例8: test_install_multiword_dependency
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install_multiword_dependency(self):
mgr = PipManager(BIN_PATH, pip_installed=True)
pip_path = os.path.join(BIN_PATH, 'pip')
with patch.object(helpers, 'logged_exec') as mock:
mgr.install('foo bar')
mock.assert_called_with([pip_path, 'install', 'foo', 'bar'])
示例9: test_install_with_options_using_equal
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install_with_options_using_equal(self):
mgr = PipManager('/usr/bin', pip_installed=True, options=['--bar=baz'])
with patch.object(helpers, 'logged_exec') as mock:
mgr.install('foo')
mock.assert_called_with(['/usr/bin/pip', 'install', 'foo', '--bar=baz'])
示例10: test_install
# 需要导入模块: from fades.pipmanager import PipManager [as 别名]
# 或者: from fades.pipmanager.PipManager import install [as 别名]
def test_install(self):
mgr = PipManager('/usr/bin', pip_installed=True)
with patch.object(helpers, 'logged_exec') as mock:
mgr.install('foo')
mock.assert_called_with(['/usr/bin/pip', 'install', 'foo'])