summaryrefslogtreecommitdiff
path: root/tools/install_venv.py
diff options
context:
space:
mode:
authorLorin Hochstein <lorin@isi.edu>2011-10-30 09:00:59 -0400
committerLorin Hochstein <lorin@isi.edu>2011-10-30 11:06:10 -0400
commitb08bd96ce5bf290ac6198079ad2dce71e675b481 (patch)
tree76710f5d0260a5bc81bee9eb243b6d4dc4158a58 /tools/install_venv.py
parent5b8133a83939fd552b569c4b034cef43907ea1ce (diff)
downloadnova-b08bd96ce5bf290ac6198079ad2dce71e675b481.tar.gz
Optional --no-site-packages in venv
Added a flag to run_tests.sh to allow user to optionally install venv with --no-site-packages. This fixes bug 880905 Change-Id: Ic645e0ec56c90b72fef526ebc9f55975d446e2ae
Diffstat (limited to 'tools/install_venv.py')
-rw-r--r--tools/install_venv.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/install_venv.py b/tools/install_venv.py
index 2ecd446e6e..67243fbf7c 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -23,6 +23,7 @@
Installation script for Nova's development virtualenv
"""
+import optparse
import os
import subprocess
import sys
@@ -128,12 +129,15 @@ def check_dependencies():
get_distro().install_virtualenv()
-def create_virtualenv(venv=VENV):
+def create_virtualenv(venv=VENV, no_site_packages=True):
"""Creates the virtual environment and installs PIP only into the
virtual environment
"""
print 'Creating venv...',
- run_command(['virtualenv', '-q', VENV])
+ if no_site_packages:
+ run_command(['virtualenv', '-q', '--no-site-packages', VENV])
+ else:
+ run_command(['virtualenv', '-q', VENV])
print 'done.'
print 'Installing pip in virtualenv...',
if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip():
@@ -191,10 +195,20 @@ def print_help():
print help
+def parse_args():
+ """Parse command-line arguments"""
+ parser = optparse.OptionParser()
+ parser.add_option("-n", "--no-site-packages", dest="no_site_packages",
+ default=False, action="store_true",
+ help="Do not inherit packages from global Python install")
+ return parser.parse_args()
+
+
def main(argv):
+ (options, args) = parse_args()
check_python_version()
check_dependencies()
- create_virtualenv()
+ create_virtualenv(no_site_packages=options.no_site_packages)
install_dependencies()
print_help()