Merge changes I94c7464b,Ibfeeb9c2
* changes: install_venv: pip install M2Crypto doesn't work on Fedora install_venv: add support for distro specific code
This commit is contained in:
commit
f9aeb86961
@ -44,7 +44,7 @@ def check_python_version():
|
||||
die("Need Python Version >= 2.6")
|
||||
|
||||
|
||||
def run_command(cmd, redirect_output=True, check_exit_code=True):
|
||||
def run_command_with_code(cmd, redirect_output=True, check_exit_code=True):
|
||||
"""
|
||||
Runs a command in an out-of-process shell, returning the
|
||||
output of that command. Working directory is ROOT.
|
||||
@ -58,30 +58,74 @@ def run_command(cmd, redirect_output=True, check_exit_code=True):
|
||||
output = proc.communicate()[0]
|
||||
if check_exit_code and proc.returncode != 0:
|
||||
die('Command "%s" failed.\n%s', ' '.join(cmd), output)
|
||||
return output
|
||||
return (output, proc.returncode)
|
||||
|
||||
|
||||
HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
|
||||
check_exit_code=False).strip())
|
||||
HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
|
||||
check_exit_code=False).strip())
|
||||
def run_command(cmd, redirect_output=True, check_exit_code=True):
|
||||
return run_command_with_code(cmd, redirect_output, check_exit_code)[0]
|
||||
|
||||
|
||||
class Distro(object):
|
||||
|
||||
def check_cmd(self, cmd):
|
||||
return bool(run_command(['which', cmd], check_exit_code=False).strip())
|
||||
|
||||
def install_virtualenv(self):
|
||||
if self.check_cmd('virtualenv'):
|
||||
return
|
||||
|
||||
if self.check_cmd('easy_install'):
|
||||
print 'Installing virtualenv via easy_install...',
|
||||
if run_command(['easy_install', 'virtualenv']):
|
||||
print 'Succeeded'
|
||||
return
|
||||
else:
|
||||
print 'Failed'
|
||||
|
||||
die('ERROR: virtualenv not found.\n\nNova development'
|
||||
' requires virtualenv, please install it using your'
|
||||
' favorite package management tool')
|
||||
|
||||
def install_m2crypto(self):
|
||||
pip_install('M2Crypto')
|
||||
|
||||
|
||||
class Fedora(Distro):
|
||||
|
||||
def check_pkg(self, pkg):
|
||||
return run_command_with_code(['rpm', '-q', pkg],
|
||||
check_exit_code=False)[1] == 0
|
||||
|
||||
def yum_install(self, pkg, **kwargs):
|
||||
run_command(['sudo', 'yum', 'install', '-y', pkg], **kwargs)
|
||||
|
||||
def install_virtualenv(self):
|
||||
if self.check_cmd('virtualenv'):
|
||||
return
|
||||
|
||||
if not self.check_pkg('python-virtualenv'):
|
||||
self.yum_install('python-virtualenv', check_exit_code=False)
|
||||
|
||||
super(Fedora, self).install_virtualenv()
|
||||
|
||||
#
|
||||
# pip install M2Crypto fails on Fedora because of
|
||||
# weird differences with OpenSSL headers
|
||||
#
|
||||
def install_m2crypto(self):
|
||||
if not self.check_pkg('m2crypto'):
|
||||
self.yum_install('m2crypto')
|
||||
|
||||
|
||||
def get_distro():
|
||||
if os.path.exists('/etc/fedora-release'):
|
||||
return Fedora()
|
||||
else:
|
||||
return Distro()
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Make sure virtualenv is in the path."""
|
||||
|
||||
if not HAS_VIRTUALENV:
|
||||
print 'not found.'
|
||||
# Try installing it via easy_install...
|
||||
if HAS_EASY_INSTALL:
|
||||
print 'Installing virtualenv via easy_install...',
|
||||
if not (run_command(['which', 'easy_install']) and
|
||||
run_command(['easy_install', 'virtualenv'])):
|
||||
die('ERROR: virtualenv not found.\n\nNova development'
|
||||
' requires virtualenv, please install it using your'
|
||||
' favorite package management tool')
|
||||
print 'done.'
|
||||
print 'done.'
|
||||
get_distro().install_virtualenv()
|
||||
|
||||
|
||||
def create_virtualenv(venv=VENV):
|
||||
@ -112,6 +156,8 @@ def install_dependencies(venv=VENV):
|
||||
|
||||
pip_install('-r', PIP_REQUIRES)
|
||||
|
||||
get_distro().install_m2crypto()
|
||||
|
||||
# Tell the virtual env how to "import nova"
|
||||
pthfile = os.path.join(venv, "lib", PY_VERSION, "site-packages",
|
||||
"nova.pth")
|
||||
|
@ -2,7 +2,6 @@ SQLAlchemy==0.6.3
|
||||
pep8==0.6.1
|
||||
pylint==0.19
|
||||
Cheetah==2.4.4
|
||||
M2Crypto
|
||||
amqplib==0.6.1
|
||||
anyjson==0.2.4
|
||||
boto==1.9b
|
||||
|
Loading…
x
Reference in New Issue
Block a user