From 97460ae2865722e9af65466659dafb0043576bca Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 1 Dec 2016 19:26:49 +0900 Subject: [PATCH] Use tox_install convention Copied from networking-midonet. Closes-Bug: #1646436 Change-Id: Ic66367eb797bddd3b7e0ffd2a65c0a3f719507f1 --- requirements.txt | 1 - tools/tox_install.sh | 16 +++++++++++ tools/tox_install_project.sh | 52 ++++++++++++++++++++++++++++++++++++ tox.ini | 2 +- 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100755 tools/tox_install.sh create mode 100755 tools/tox_install_project.sh diff --git a/requirements.txt b/requirements.txt index eb7f8495..15521b2b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ pbr>=1.6 # Apache-2.0 Babel>=2.3.4 # BSD --e git://git.openstack.org/openstack/neutron.git@master#egg=neutron diff --git a/tools/tox_install.sh b/tools/tox_install.sh new file mode 100755 index 00000000..23f5d8ab --- /dev/null +++ b/tools/tox_install.sh @@ -0,0 +1,16 @@ +#! /bin/sh + +set -e + +DIR=$(dirname $0) +${DIR}/tox_install_project.sh neutron neutron $* + +CONSTRAINTS_FILE=$1 +shift + +install_cmd="pip install" +if [ $CONSTRAINTS_FILE != "unconstrained" ]; then + install_cmd="$install_cmd -c$CONSTRAINTS_FILE" +fi + +$install_cmd -U $* diff --git a/tools/tox_install_project.sh b/tools/tox_install_project.sh new file mode 100755 index 00000000..e95dd836 --- /dev/null +++ b/tools/tox_install_project.sh @@ -0,0 +1,52 @@ +#!/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} + +PROJ=$1 +MOD=$2 +shift 2 + +ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner +neutron_installed=$(echo "import ${MOD}" | python 2>/dev/null ; echo $?) +BRANCH_NAME=master + +set -e + +CONSTRAINTS_FILE=$1 +shift + +install_cmd="pip install" +if [ $CONSTRAINTS_FILE != "unconstrained" ]; then + install_cmd="$install_cmd -c$CONSTRAINTS_FILE" +fi + +if [ $neutron_installed -eq 0 ]; then + echo "ALREADY INSTALLED" > /tmp/tox_install-${PROJ}.txt + echo "${PROJ} already installed; using existing package" +elif [ -x "$ZUUL_CLONER" ]; then + echo "ZUUL CLONER" > /tmp/tox_install-${PROJ}.txt + cwd=$(/bin/pwd) + cd /tmp + $ZUUL_CLONER --cache-dir \ + /opt/git \ + --branch ${BRANCH_NAME} \ + git://git.openstack.org \ + openstack/${PROJ} + cd openstack/${PROJ} + $install_cmd -e . + cd "$cwd" +else + echo "PIP HARDCODE" > /tmp/tox_install-${PROJ}.txt + $install_cmd -U -egit+https://git.openstack.org/openstack/${PROJ}@${BRANCH_NAME}#egg=${PROJ} +fi diff --git a/tox.ini b/tox.ini index 9d99c117..4f285eaa 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ skipsdist = True setenv = VIRTUAL_ENV={envdir} PYTHONWARNINGS=default::DeprecationWarning usedevelop = True -install_command = pip install -U {opts} {packages} +install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = find . -type f -name "*.py[c|o]" -delete