diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-10-13 04:49:38 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-10-13 04:49:38 +0000 |
| commit | f9aeb869618fc7eafe8cfc2f28430f505bedb782 (patch) | |
| tree | b3a19e24732fec46f55c59687cdbe9283792f777 | |
| parent | 7d34fb75050b7579632de6f7f3bc6818ff6465cd (diff) | |
| parent | 6c9743665629d7cf74de83202b4ba2909c43275e (diff) | |
| download | nova-f9aeb869618fc7eafe8cfc2f28430f505bedb782.tar.gz nova-f9aeb869618fc7eafe8cfc2f28430f505bedb782.tar.xz nova-f9aeb869618fc7eafe8cfc2f28430f505bedb782.zip | |
Merge changes I94c7464b,Ibfeeb9c2
* changes:
install_venv: pip install M2Crypto doesn't work on Fedora
install_venv: add support for distro specific code
| -rw-r--r-- | tools/install_venv.py | 84 | ||||
| -rw-r--r-- | tools/pip-requires | 1 |
2 files changed, 65 insertions, 20 deletions
diff --git a/tools/install_venv.py b/tools/install_venv.py index 912d0a251..78447c860 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -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] -def check_dependencies(): - """Make sure virtualenv is in the path.""" +class Distro(object): - if not HAS_VIRTUALENV: - print 'not found.' - # Try installing it via easy_install... - if HAS_EASY_INSTALL: + 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 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.' + 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(): + 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") diff --git a/tools/pip-requires b/tools/pip-requires index bafca94ba..06940337b 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -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 |
