diff --git a/requirements.txt b/requirements.txt index 6ead9fe..95137a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ pbr>=0.6,!=0.7,<1.0 Babel>=1.3 --e git://git.openstack.org/openstack/neutron.git#egg=neutron diff --git a/tools/add_neutron_patches.sh b/tools/add_neutron_patches.sh index 166a78c..0ebe772 100755 --- a/tools/add_neutron_patches.sh +++ b/tools/add_neutron_patches.sh @@ -2,17 +2,17 @@ echo "Adding neutron patches into the testing env" -DIRECTORY="$1/src/neutron" +NEUTRON_SRC="$1" LIST_SRC="$2/test-patches.txt" -echo "Checking Directory Existance: $DIRECTORY" +echo "Checking Directory Existence: $NEUTRON_SRC" -if [ ! -d "$DIRECTORY" ]; then - echo "Directory $DIRECTORY does not exist, aborting..." +if [ ! -d "$NEUTRON_SRC" ]; then + echo "Directory $NEUTRON_SRC does not exist, aborting..." exit 1 fi -cd $DIRECTORY +cd $NEUTRON_SRC # Ensure we're on toxBranch not master or other branches git checkout -b toxBranch 2> /dev/null diff --git a/tools/tox_install.sh b/tools/tox_install.sh new file mode 100755 index 0000000..aa275d9 --- /dev/null +++ b/tools/tox_install.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# Many of neutron's repos suffer from the problem of depending on neutron, +# 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 neutron 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 +neutron_installed=$(echo "import neutron" | python 2>/dev/null ; echo $?) + +set -ex + +cwd=$(/bin/pwd) + +if [ $neutron_installed -eq 0 ]; then + echo "ALREADY INSTALLED" > /tmp/tox_install.txt + echo "Neutron already installed; using existing package" +elif [ -x "$ZUUL_CLONER" ]; then + echo "ZUUL CLONER" > /tmp/tox_install.txt + cd /tmp + $ZUUL_CLONER --cache-dir \ + /opt/git \ + git://git.openstack.org \ + openstack/neutron + cd openstack/neutron + $cwd/tools/add_neutron_patches.sh /tmp/openstack/neutron $cwd + pip install -e . + cd "$cwd" +else + echo "PIP HARDCODE" > /tmp/tox_install.txt + pip install -U -egit+https://git.openstack.org/openstack/neutron#egg=neutron + $cwd/tools/add_neutron_patches.sh $VIRTUAL_ENV/src/neutron $cwd + pip install -U -e $VIRTUAL_ENV/src/neutron +fi + +pip install -U $* +exit $? diff --git a/tox.ini b/tox.ini index f144940..12af72e 100644 --- a/tox.ini +++ b/tox.ini @@ -9,11 +9,11 @@ skipsdist = True setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 usedevelop = True -install_command = pip install -r requirements.txt -U {opts} {packages} -deps = -r{toxinidir}/test-requirements.txt +install_command = {toxinidir}/tools/tox_install.sh {opts} {packages} +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt whitelist_externals = sh commands = - sh {toxinidir}/tools/add_neutron_patches.sh {envdir} {toxinidir} sh tools/pretty_tox.sh '{posargs}' # there is also secret magic in pretty_tox.sh which lets you run in a fail only # mode. To do this define the TRACE_FAILONLY environmental variable.