diff options
| author | Clark Boylan <clark.boylan@gmail.com> | 2013-05-08 11:32:26 -0700 |
|---|---|---|
| committer | Clark Boylan <clark.boylan@gmail.com> | 2013-05-10 15:39:08 -0700 |
| commit | 548b52336f19ea91dde3076ff85dbce9735f5420 (patch) | |
| tree | 2359977335354d9c8d4ccee765fa716b05e8b716 /tools | |
| parent | 8f80678677e2e47bac9ad0ac9d7fc1cb27d34788 (diff) | |
| download | python-keystoneclient-548b52336f19ea91dde3076ff85dbce9735f5420.tar.gz | |
Perform oslo-incubator code sync.
run_tests.sh cannot install a virtualenv with tools/install_venv.py as
tools/install_venv_common.py depends on oslo.config which is an external
dependency. The virtualenv installer should not depend on any external
dependencies. Fix this by performing a code sync with oslo-incubator.
Note this adds a new dependency on six and changes the way versioning is
determined.
Change-Id: Ifb67bbfeec4eabc943c2a88a34fe535c57f174a1
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/install_venv_common.py | 67 | ||||
| -rw-r--r-- | tools/pip-requires | 1 |
2 files changed, 29 insertions, 39 deletions
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index ebd8940..914fcf1 100644 --- a/tools/install_venv_common.py +++ b/tools/install_venv_common.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2013 OpenStack, LLC +# Copyright 2013 OpenStack Foundation # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -18,23 +18,20 @@ """Provides methods needed by installation script for OpenStack development virtual environments. +Since this script is used to bootstrap a virtualenv from the system's Python +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 import sys -possible_topdir = os.getcwd() -if os.path.exists(os.path.join(possible_topdir, "keystoneclient", - "__init__.py")): - sys.path.insert(0, possible_topdir) - - -from oslo.config import cfg - - class InstallVenv(object): def __init__(self, root, venv, pip_requires, test_requires, py_version, @@ -47,7 +44,7 @@ class InstallVenv(object): self.project = project def die(self, message, *args): - print >> sys.stderr, message % args + print(message % args, file=sys.stderr) sys.exit(1) def check_python_version(self): @@ -58,7 +55,7 @@ class InstallVenv(object): check_exit_code=True): """Runs a command in an out-of-process shell. - Returns the output of that command. Working directory is ROOT. + Returns the output of that command. Working directory is self.root. """ if redirect_output: stdout = subprocess.PIPE @@ -94,20 +91,20 @@ class InstallVenv(object): virtual environment. """ if not os.path.isdir(self.venv): - print 'Creating venv...', + print('Creating venv...', end=' ') 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 virtualenv...', + print('done.') + print('Installing pip in venv...', end=' ') 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): @@ -116,7 +113,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. @@ -139,17 +136,12 @@ class InstallVenv(object): def parse_args(self, argv): """Parses command-line arguments.""" - cli_opts = [ - cfg.BoolOpt('no-site-packages', - default=False, - short='n', - help="Do not inherit packages from global Python" - "install"), - ] - CLI = cfg.ConfigOpts() - CLI.register_cli_opts(cli_opts) - CLI(argv[1:]) - return CLI + parser = optparse.OptionParser() + parser.add_option('-n', '--no-site-packages', + action='store_true', + help="Do not inherit packages from global Python " + "install") + return parser.parse_args(argv[1:])[0] class Distro(InstallVenv): @@ -163,12 +155,12 @@ class Distro(InstallVenv): return if self.check_cmd('easy_install'): - print 'Installing virtualenv via easy_install...', + print('Installing virtualenv via easy_install...', end=' ') 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' @@ -193,19 +185,16 @@ class Fedora(Distro): return self.run_command_with_code(['rpm', '-q', pkg], check_exit_code=False)[1] == 0 - def yum_install(self, pkg, **kwargs): - print "Attempting to install '%s' via yum" % pkg - self.run_command(['sudo', 'yum', 'install', '-y', pkg], **kwargs) - def apply_patch(self, originalfile, patchfile): - self.run_command(['patch', originalfile, patchfile]) + self.run_command(['patch', '-N', originalfile, patchfile], + check_exit_code=False) 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) + self.die("Please install 'python-virtualenv'.") super(Fedora, self).install_virtualenv() @@ -223,7 +212,7 @@ class Fedora(Distro): # Install "patch" program if it's not there if not self.check_pkg('patch'): - self.yum_install('patch') + self.die("Please install 'patch'.") # Apply the eventlet patch self.apply_patch(os.path.join(self.venv, 'lib', self.py_version, diff --git a/tools/pip-requires b/tools/pip-requires index 2469771..47d2f9a 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -3,4 +3,5 @@ iso8601>=0.1.4 prettytable>=0.6,<0.8 requests>=0.8.8 simplejson +six oslo.config>=1.1.0 |
