Move virtualenv installation out of the makefile.
Also adds some tools for dealing with virtualenvs to the tools directory.
This commit is contained in:
parent
17c9156487
commit
4def4e93ca
@ -1 +1,2 @@
|
|||||||
run_tests.err.log
|
run_tests.err.log
|
||||||
|
.nova-venv
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ keys
|
|||||||
build/*
|
build/*
|
||||||
build-stamp
|
build-stamp
|
||||||
nova.egg-info
|
nova.egg-info
|
||||||
|
.nova-venv
|
||||||
|
28
Makefile
28
Makefile
@ -1,27 +1,27 @@
|
|||||||
venv=.venv
|
venv=.nova-venv
|
||||||
with_venv=source $(venv)/bin/activate
|
with_venv=tools/with_venv.sh
|
||||||
installed=$(venv)/lib/python2.6/site-packages
|
|
||||||
twisted=$(installed)/twisted/__init__.py
|
|
||||||
|
|
||||||
|
build:
|
||||||
|
# Nothing to do
|
||||||
|
|
||||||
test: python-dependencies $(twisted)
|
test: $(venv)
|
||||||
$(with_venv) && python run_tests.py
|
$(with_venv) python run_tests.py
|
||||||
|
|
||||||
|
test-system:
|
||||||
|
python run_tests.py
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf _trial_temp
|
rm -rf _trial_temp
|
||||||
rm -rf keys
|
rm -rf keys
|
||||||
rm -rf instances
|
rm -rf instances
|
||||||
rm -rf networks
|
rm -rf networks
|
||||||
|
rm run_tests.err.log
|
||||||
|
|
||||||
clean-all: clean
|
clean-all: clean
|
||||||
rm -rf $(venv)
|
rm -rf $(venv)
|
||||||
|
|
||||||
python-dependencies: $(venv)
|
|
||||||
pip install -q -E $(venv) -r tools/pip-requires
|
|
||||||
|
|
||||||
$(venv):
|
$(venv):
|
||||||
pip install -q virtualenv
|
@echo "You need to install the Nova virtualenv before you can run this."
|
||||||
virtualenv -q --no-site-packages $(venv)
|
@echo ""
|
||||||
|
@echo "Please run tools/install_venv.py"
|
||||||
$(twisted):
|
@exit 1
|
||||||
pip install -q -E $(venv) http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz
|
|
||||||
|
3
tools/activate_venv.sh
Normal file
3
tools/activate_venv.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
_TOOLS=`dirname $0`
|
||||||
|
_VENV=$_TOOLS/../.nova-venv
|
||||||
|
source $_VENV/bin/activate
|
95
tools/install_venv.py
Normal file
95
tools/install_venv.py
Normal file
@ -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 <your command>
|
||||||
|
|
||||||
|
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)
|
@ -5,10 +5,11 @@ anyjson==0.2.4
|
|||||||
boto==2.0b1
|
boto==2.0b1
|
||||||
carrot==0.10.5
|
carrot==0.10.5
|
||||||
lockfile==0.8
|
lockfile==0.8
|
||||||
mox==0.5.0
|
|
||||||
python-daemon==1.5.5
|
python-daemon==1.5.5
|
||||||
python-gflags==1.3
|
python-gflags==1.3
|
||||||
redis==2.0.0
|
redis==2.0.0
|
||||||
tornado==1.0
|
tornado==1.0
|
||||||
wsgiref==0.1.2
|
wsgiref==0.1.2
|
||||||
zope.interface==3.6.1
|
zope.interface==3.6.1
|
||||||
|
mox==0.5.0
|
||||||
|
-f http://pymox.googlecode.com/files/mox-0.5.0.tar.gz
|
||||||
|
4
tools/with_venv.sh
Executable file
4
tools/with_venv.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
TOOLS=`dirname $0`
|
||||||
|
VENV=$TOOLS/../.nova-venv
|
||||||
|
source $VENV/bin/activate && $@
|
Loading…
Reference in New Issue
Block a user