From a766736b79f794f745438dd597f2aa529ad62ddc Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Fri, 23 Jul 2010 04:44:23 +0200 Subject: Adds a Makefile to fill dependencies for testing. Depends upon pip being installed, but pip is pretty much the standard nowadays and is just an easy_install away if it isn't there. The only dependency installed on to the system is virtualenv which is used to make the other dependencies local to the current environment. Does not remove the need to install redis by hand, though I am in favor of making that possible (using aptitude on linux and brew on os x) I look forward to cutting away at some of these dependencies in further commits. --- tools/pip-requires | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tools/pip-requires (limited to 'tools') diff --git a/tools/pip-requires b/tools/pip-requires new file mode 100644 index 000000000..edb5fc01c --- /dev/null +++ b/tools/pip-requires @@ -0,0 +1,14 @@ +IPy==0.70 +M2Crypto==0.20.2 +amqplib==0.6.1 +anyjson==0.2.4 +boto==2.0b1 +carrot==0.10.5 +lockfile==0.8 +mox==0.5.0 +python-daemon==1.5.5 +python-gflags==1.3 +redis==2.0.0 +tornado==1.0 +wsgiref==0.1.2 +zope.interface==3.6.1 -- cgit From 6d3331e831ec147916d0d605958f61ca69eee9a8 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 26 Jul 2010 23:16:49 +0200 Subject: Move virtualenv installation out of the makefile. Also adds some tools for dealing with virtualenvs to the tools directory. --- tools/activate_venv.sh | 3 ++ tools/install_venv.py | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/pip-requires | 3 +- tools/with_venv.sh | 4 +++ 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 tools/activate_venv.sh create mode 100644 tools/install_venv.py create mode 100755 tools/with_venv.sh (limited to 'tools') diff --git a/tools/activate_venv.sh b/tools/activate_venv.sh new file mode 100644 index 000000000..d12cb3491 --- /dev/null +++ b/tools/activate_venv.sh @@ -0,0 +1,3 @@ +_TOOLS=`dirname $0` +_VENV=$_TOOLS/../.nova-venv +source $_VENV/bin/activate diff --git a/tools/install_venv.py b/tools/install_venv.py new file mode 100644 index 000000000..720dcc0d9 --- /dev/null +++ b/tools/install_venv.py @@ -0,0 +1,95 @@ +""" +Installation script for Nova's development virtualenv +""" + +import os +import subprocess +import sys +import textwrap + + +ROOT = os.path.dirname(os.path.dirname(__file__)) +VENV = os.path.join(ROOT, '.nova-venv') +PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires') +TWISTED_NOVA='http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz' + + +def die(message, *args): + print >>sys.stderr, message % args + sys.exit(1) + + +def run_command(cmd, redirect_output=True, error_ok=False): + # Useful for debugging: + #print >>sys.stderr, ' '.join(cmd) + if redirect_output: + stdout = subprocess.PIPE + else: + stdout = None + + proc = subprocess.Popen(cmd, stdout=stdout) + output = proc.communicate()[0] + if not error_ok and proc.returncode != 0: + die('Command "%s" failed.\n%s', ' '.join(cmd), output) + return output + + +def check_dependencies(): + """Make sure pip and virtualenv are on the path.""" + print 'Checking for pip...', + if not run_command(['which', 'pip']).strip(): + die('ERROR: pip not found.\n\nNova development requires pip,' + ' please install it using your favorite package management tool') + print 'done.' + + print 'Checking for virtualenv...', + if not run_command(['which', 'virtualenv']).strip(): + die('ERROR: virtualenv not found.\n\nNova development requires virtualenv,' + ' please install it using your favorite package management tool') + print 'done.' + + +def create_virtualenv(venv=VENV): + print 'Creating venv...', + run_command(['virtualenv', '-q', '--no-site-packages', VENV]) + print 'done.' + + +def install_dependencies(venv=VENV): + print 'Installing dependencies with pip (this can take a while)...' + run_command(['pip', 'install', '-E', venv, '-r', PIP_REQUIRES], + redirect_output=False) + run_command(['pip', 'install', '-E', venv, TWISTED_NOVA], + redirect_output=False) + + +def print_help(): + help = """ + Nova development environment setup is complete. + + Nova development uses virtualenv to track and manage Python dependencies + while in development and testing. + + To activate the Nova virtualenv for the extent of your current shell session + you can run: + + $ source tools/activate_venv.sh + + Or, if you prefer, you can run commands in the virtualenv on a case by case + basis by running: + + $ tools/with_venv.sh + + Also, run_tests.sh will automatically use the virtualenv. + """ + print help + + +def main(argv): + check_dependencies() + create_virtualenv() + install_dependencies() + print_help() + +if __name__ == '__main__': + main(sys.argv) diff --git a/tools/pip-requires b/tools/pip-requires index edb5fc01c..4eb47ca2b 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -5,10 +5,11 @@ anyjson==0.2.4 boto==2.0b1 carrot==0.10.5 lockfile==0.8 -mox==0.5.0 python-daemon==1.5.5 python-gflags==1.3 redis==2.0.0 tornado==1.0 wsgiref==0.1.2 zope.interface==3.6.1 +mox==0.5.0 +-f http://pymox.googlecode.com/files/mox-0.5.0.tar.gz diff --git a/tools/with_venv.sh b/tools/with_venv.sh new file mode 100755 index 000000000..51468a334 --- /dev/null +++ b/tools/with_venv.sh @@ -0,0 +1,4 @@ +#!/bin/sh +TOOLS=`dirname $0` +VENV=$TOOLS/../.nova-venv +source $VENV/bin/activate && $@ -- cgit From 4373ca830fe93ddff70cf02bc366303d6b001ae9 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 26 Jul 2010 18:57:24 -0700 Subject: Fixes to the virtualenv installer --- tools/activate_venv.sh | 1 + tools/install_venv.py | 3 +-- tools/with_venv.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/activate_venv.sh b/tools/activate_venv.sh index d12cb3491..376db5b96 100644 --- a/tools/activate_venv.sh +++ b/tools/activate_venv.sh @@ -1,3 +1,4 @@ +#!/bin/bash _TOOLS=`dirname $0` _VENV=$_TOOLS/../.nova-venv source $_VENV/bin/activate diff --git a/tools/install_venv.py b/tools/install_venv.py index 720dcc0d9..c35af434b 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -5,7 +5,6 @@ Installation script for Nova's development virtualenv import os import subprocess import sys -import textwrap ROOT = os.path.dirname(os.path.dirname(__file__)) @@ -80,7 +79,7 @@ def print_help(): $ tools/with_venv.sh - Also, run_tests.sh will automatically use the virtualenv. + Also, make test will automatically use the virtualenv. """ print help diff --git a/tools/with_venv.sh b/tools/with_venv.sh index 51468a334..99d1ac18f 100755 --- a/tools/with_venv.sh +++ b/tools/with_venv.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash TOOLS=`dirname $0` VENV=$TOOLS/../.nova-venv source $VENV/bin/activate && $@ -- cgit From 4199dab2e761efc6cb2d9af353f5f09c943a2d2f Mon Sep 17 00:00:00 2001 From: Paul Voccio Date: Mon, 26 Jul 2010 23:23:44 -0500 Subject: resolving conflict w/ merge, cleaning up virtenv setups --- tools/activate_venv.sh | 4 ---- tools/install_venv.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 tools/activate_venv.sh (limited to 'tools') diff --git a/tools/activate_venv.sh b/tools/activate_venv.sh deleted file mode 100644 index 376db5b96..000000000 --- a/tools/activate_venv.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -_TOOLS=`dirname $0` -_VENV=$_TOOLS/../.nova-venv -source $_VENV/bin/activate diff --git a/tools/install_venv.py b/tools/install_venv.py index c35af434b..0b35fc8e9 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -72,7 +72,7 @@ def print_help(): To activate the Nova virtualenv for the extent of your current shell session you can run: - $ source tools/activate_venv.sh + $ source .nova-venv/bin/activate Or, if you prefer, you can run commands in the virtualenv on a case by case basis by running: -- cgit