Install horizon more efficiently

This patch introduces a pip install wrapper script which
checks horizon is installed and installs it from efficient way
(try zuul-cloner first and then use the horizon git repo).

This can also avoid a problem reported in bug 1540328.

When run_tests.sh is used, horizon is installed by
the customized install_venv.py now.
run_tests.sh is not directly used in our gate jobs,
so we can always install horizon using git repo.

This idea is borrowed from neutron subpurojects.

Change-Id: Ice304957823ac1d2c63f7c417c0dc9bb9c1fa757
Related-Bug: #1540328
This commit is contained in:
Akihiro Motoki 2016-02-08 13:47:24 +09:00
parent ecdd89583a
commit 64b6e973bd
4 changed files with 65 additions and 5 deletions

View File

@ -2,8 +2,6 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-e git://github.com/openstack/horizon.git#egg=horizon
hacking<0.11,>=0.10.0
coverage>=3.6 # Apache-2.0
ddt>=1.0.1 # MIT

View File

@ -32,6 +32,7 @@ VENV = os.path.join(ROOT, '.venv')
WITH_VENV = os.path.join(ROOT, 'tools', 'with_venv.sh')
PIP_REQUIRES = os.path.join(ROOT, 'requirements.txt')
TEST_REQUIRES = os.path.join(ROOT, 'test-requirements.txt')
PIP_INSTALL_WRAPPER = os.path.join(ROOT, 'tools', 'pip_install.sh')
def die(message, *args):
@ -113,11 +114,16 @@ def pip_install(*args):
run_command(args, redirect_output=False)
def pip_install_with_horizon(*args):
args = [WITH_VENV, PIP_INSTALL_WRAPPER, 'unconstrained'] + list(args)
run_command(args, redirect_output=False)
def install_dependencies(venv=VENV):
print "Installing dependencies..."
print "(This may take several minutes, don't panic)"
pip_install('-r', TEST_REQUIRES)
pip_install('-r', PIP_REQUIRES)
pip_install_with_horizon('-r', TEST_REQUIRES)
pip_install_with_horizon('-r', PIP_REQUIRES)
# Tell the virtual env how to "import dashboard"
py = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])

56
tools/pip_install.sh Executable file
View File

@ -0,0 +1,56 @@
#!/bin/sh
# The original script is borrowed from neutron-* repos.
# Many of horizon's repos suffer from the problem of depending on horizon,
# but it not existing on pypi.
# This wrapper for tox's package installer will use the existing package
# if it exists, else use zuul-cloner if that program exists, else grab it
# from horizon master via a hard-coded URL. That last case should only
# happen with devs running unit tests locally.
# From the tox.ini config page:
# install_command=ARGV
# default:
# pip install {opts} {packages}
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
BRANCH_NAME=master
horizon_installed=$(echo "import horizon" | python 2>/dev/null ; echo $?)
set -e
install_cmd="pip install"
if [ "$1" = "constrained" ]; then
install_cmd="$install_cmd $2"
shift
fi
shift
if [ $horizon_installed -eq 0 ]; then
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
echo "Horizon already installed; using existing package"
elif [ -x "$ZUUL_CLONER" ]; then
export ZUUL_BRANCH=${ZUUL_BRANCH-$BRANCH}
echo "ZUUL CLONER" > /tmp/tox_install.txt
cwd=$(/bin/pwd)
cd /tmp
$ZUUL_CLONER --cache-dir \
/opt/git \
--branch $BRANCH_NAME \
git://git.openstack.org \
openstack/horizon
cd openstack/horizon
$install_cmd -e .
cd "$cwd"
else
echo "PIP HARDCODE" > /tmp/tox_install.txt
if [ -z "$HORIZON_PIP_LOCATION" ]; then
HORIZON_PIP_LOCATION="git+https://git.openstack.org/openstack/horizon@$BRANCH_NAME#egg=horizon"
fi
$install_cmd -U -e ${HORIZON_PIP_LOCATION}
fi
$install_cmd -U $*
exit $?

View File

@ -5,7 +5,7 @@ skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
install_command = {toxinidir}/tools/pip_install.sh unconstrained {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt