Sync charm-helpers

This commit is contained in:
Corey Bryant 2015-05-07 14:39:35 +00:00
parent 1c594dc89b
commit 426bce4c99
2 changed files with 26 additions and 15 deletions

View File

@ -611,9 +611,11 @@ def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
juju_log('Installing git repo from dir: {}'.format(repo_dir))
if http_proxy:
pip_install(repo_dir, proxy=http_proxy, venv=True)
pip_install(repo_dir, proxy=http_proxy,
venv=os.path.join(parent_dir, 'venv'))
else:
pip_install(repo_dir, venv=True)
pip_install(repo_dir,
venv=os.path.join(parent_dir, 'venv'))
return repo_dir
@ -636,6 +638,23 @@ def _git_update_requirements(package_dir, reqs_dir):
os.chdir(orig_dir)
def git_pip_venv_dir(projects_yaml):
"""
Return the pip virtualenv path.
"""
parent_dir = '/mnt/openstack-git'
if not projects_yaml:
return
projects = yaml.load(projects_yaml)
if 'directory' in projects.keys():
parent_dir = projects['directory']
return os.path.join(parent_dir, 'venv')
def git_src_dir(projects_yaml, project):
"""
Return the directory where the specified project's source is located.

View File

@ -30,8 +30,6 @@ except ImportError:
apt_install('python-pip')
from pip import main as pip_execute
pip_venv_path = None
__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
@ -56,10 +54,10 @@ def pip_install_requirements(requirements, **options):
pip_execute(command)
def pip_install(package, fatal=False, upgrade=False, venv=False, **options):
def pip_install(package, fatal=False, upgrade=False, venv=None, **options):
"""Install a python package"""
if venv:
venv_python = os.path.join(pip_venv_path, 'bin/pip')
venv_python = os.path.join(venv, 'bin/pip')
command = [venv_python, "install"]
else:
command = ["install"]
@ -110,17 +108,11 @@ def pip_list():
def pip_create_virtualenv(path=None):
"""Create an isolated Python environment."""
global pip_venv_path
apt_install('python-virtualenv')
if path:
pip_venv_path = path
venv_path = path
else:
pip_venv_path = os.path.join(charm_dir(), 'venv')
venv_path = os.path.join(charm_dir(), 'venv')
subprocess.check_call(['virtualenv', pip_venv_path])
def pip_get_virtualenv_path():
return pip_venv_path
subprocess.check_call(['virtualenv', venv_path])