summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDevananda van der Veen <devananda.vdv@gmail.com>2013-05-03 14:01:05 -0700
committerDevananda van der Veen <devananda.vdv@gmail.com>2013-05-07 16:47:55 -0700
commit0480834614476997e297187ec43d7ca500c8dcdb (patch)
tree4868179339019c9490b364b5af6c28bc3d7a5425 /tools
parent05e9ce4c489adc24c4f70d01f4182a9d64fcf582 (diff)
downloadironic-0480834614476997e297187ec43d7ca500c8dcdb.tar.gz
Rename files and fix things.
Diffstat (limited to 'tools')
-rw-r--r--tools/__init__.py0
-rw-r--r--tools/install_venv.py74
-rw-r--r--tools/install_venv_common.py22
-rw-r--r--tools/patch_tox_venv.py6
-rwxr-xr-xtools/with_venv.sh7
5 files changed, 94 insertions, 15 deletions
diff --git a/tools/__init__.py b/tools/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tools/__init__.py
+++ /dev/null
diff --git a/tools/install_venv.py b/tools/install_venv.py
new file mode 100644
index 000000000..4f6095944
--- /dev/null
+++ b/tools/install_venv.py
@@ -0,0 +1,74 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Copyright 2010 OpenStack Foundation
+# Copyright 2013 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import os
+import sys
+
+import install_venv_common as install_venv
+
+
+def print_help(venv, root):
+ help = """
+ Ironic development environment setup is complete.
+
+ Ironic development uses virtualenv to track and manage Python dependencies
+ while in development and testing.
+
+ To activate the Ironic virtualenv for the extent of your current shell
+ session you can run:
+
+ $ source %s/bin/activate
+
+ Or, if you prefer, you can run commands in the virtualenv on a case by case
+ basis by running:
+
+ $ %s/tools/with_venv.sh <your command>
+
+ Also, make test will automatically use the virtualenv.
+ """
+ print help % (venv, root)
+
+
+def main(argv):
+ root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+ if os.environ.get('tools_path'):
+ root = os.environ['tools_path']
+ venv = os.path.join(root, '.venv')
+ if os.environ.get('venv'):
+ venv = os.environ['venv']
+
+ pip_requires = os.path.join(root, 'tools', 'pip-requires')
+ test_requires = os.path.join(root, 'tools', 'test-requires')
+ py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
+ project = 'Nova'
+ install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
+ py_version, project)
+ options = install.parse_args(argv)
+ install.check_python_version()
+ install.check_dependencies()
+ install.create_virtualenv(no_site_packages=options.no_site_packages)
+ install.install_dependencies()
+ install.post_process()
+ print_help(venv, root)
+
+if __name__ == '__main__':
+ main(sys.argv)
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py
index 914fcf17e..0401a958f 100644
--- a/tools/install_venv_common.py
+++ b/tools/install_venv_common.py
@@ -24,8 +24,6 @@ environment, it should be kept strictly compatible with Python 2.6.
Synced in from openstack-common
"""
-from __future__ import print_function
-
import optparse
import os
import subprocess
@@ -44,7 +42,7 @@ class InstallVenv(object):
self.project = project
def die(self, message, *args):
- print(message % args, file=sys.stderr)
+ print >> sys.stderr, message % args
sys.exit(1)
def check_python_version(self):
@@ -91,20 +89,20 @@ class InstallVenv(object):
virtual environment.
"""
if not os.path.isdir(self.venv):
- print('Creating venv...', end=' ')
+ print 'Creating venv...',
if no_site_packages:
self.run_command(['virtualenv', '-q', '--no-site-packages',
self.venv])
else:
self.run_command(['virtualenv', '-q', self.venv])
- print('done.')
- print('Installing pip in venv...', end=' ')
+ print 'done.'
+ print 'Installing pip in venv...',
if not self.run_command(['tools/with_venv.sh', 'easy_install',
'pip>1.0']).strip():
self.die("Failed to install pip.")
- print('done.')
+ print 'done.'
else:
- print("venv already exists...")
+ print "venv already exists..."
pass
def pip_install(self, *args):
@@ -113,7 +111,7 @@ class InstallVenv(object):
redirect_output=False)
def install_dependencies(self):
- print('Installing dependencies with pip (this can take a while)...')
+ print 'Installing dependencies with pip (this can take a while)...'
# First things first, make sure our venv has the latest pip and
# distribute.
@@ -155,12 +153,12 @@ class Distro(InstallVenv):
return
if self.check_cmd('easy_install'):
- print('Installing virtualenv via easy_install...', end=' ')
+ print 'Installing virtualenv via easy_install...',
if self.run_command(['easy_install', 'virtualenv']):
- print('Succeeded')
+ print 'Succeeded'
return
else:
- print('Failed')
+ print 'Failed'
self.die('ERROR: virtualenv not found.\n\n%s development'
' requires virtualenv, please install it using your'
diff --git a/tools/patch_tox_venv.py b/tools/patch_tox_venv.py
index ac2fc9243..399acbcfc 100644
--- a/tools/patch_tox_venv.py
+++ b/tools/patch_tox_venv.py
@@ -17,7 +17,7 @@
import os
import sys
-import tools.install_venv_common as install_venv
+import install_venv_common as install_venv
def main(argv):
@@ -25,8 +25,8 @@ def main(argv):
venv = os.environ['VIRTUAL_ENV']
- pip_requires = os.path.join(root, 'requirements.txt')
- test_requires = os.path.join(root, 'test-requirements.txt')
+ pip_requires = os.path.join(root, 'tools', 'pip-requires')
+ test_requires = os.path.join(root, 'tools', 'test-requires')
py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
project = 'Nova'
install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
diff --git a/tools/with_venv.sh b/tools/with_venv.sh
new file mode 100755
index 000000000..94e05c127
--- /dev/null
+++ b/tools/with_venv.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+tools_path=${tools_path:-$(dirname $0)}
+venv_path=${venv_path:-${tools_path}}
+venv_dir=${venv_name:-/../.venv}
+TOOLS=${tools_path}
+VENV=${venv:-${venv_path}/${venv_dir}}
+source ${VENV}/bin/activate && "$@"