summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-12-06 13:18:00 +0000
committerGerrit Code Review <review@openstack.org>2017-12-06 13:18:00 +0000
commit61a5b7d3b7b89483fbd04c091076fe0e8ff65f4a (patch)
tree3a75e10ee340a005d3657189772b2f7608f1d57a
parent09aaff41fa3c5b60b456cb9aff9e529f8e4d6bdf (diff)
parent199f0e0b7cd43cb963341ce2af398603259c65ff (diff)
Merge "Align tox_install.sh with other projects"
-rwxr-xr-xtools/pip_install.sh52
-rwxr-xr-xtools/tox_install.sh65
-rw-r--r--tox.ini6
3 files changed, 68 insertions, 55 deletions
diff --git a/tools/pip_install.sh b/tools/pip_install.sh
deleted file mode 100755
index c7568eb..0000000
--- a/tools/pip_install.sh
+++ /dev/null
@@ -1,52 +0,0 @@
1#!/bin/sh
2
3# This script is borrowed from Sahara who borrowed from neutron-* repos.
4
5# Many of horizon's repos suffer from the problem of depending on horizon,
6# but it not existing on pypi.
7
8# This wrapper for tox's package installer will use the existing package
9# if it exists, else use zuul-cloner if that program exists, else grab it
10# from horizon master via a hard-coded URL. That last case should only
11# happen with devs running unit tests locally.
12
13# From the tox.ini config page:
14# install_command=ARGV
15# default:
16# pip install {opts} {packages}
17
18ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
19BRANCH_NAME=master
20horizon_installed=$(echo "import horizon" | python 2>/dev/null ; echo $?)
21
22set -e
23
24install_cmd="pip install $1"
25shift
26
27if [ $horizon_installed -eq 0 ]; then
28 echo "ALREADY INSTALLED" > /tmp/tox_install.txt
29 echo "Horizon already installed; using existing package"
30elif [ -x "$ZUUL_CLONER" ]; then
31 export ZUUL_BRANCH=${ZUUL_BRANCH-$BRANCH}
32 echo "ZUUL CLONER" > /tmp/tox_install.txt
33 cwd=$(/bin/pwd)
34 cd /tmp
35 $ZUUL_CLONER --cache-dir \
36 /opt/git \
37 --branch $BRANCH_NAME \
38 git://git.openstack.org \
39 openstack/horizon
40 cd openstack/horizon
41 $install_cmd -e .
42 cd "$cwd"
43else
44 echo "PIP HARDCODE" > /tmp/tox_install.txt
45 if [ -z "$HORIZON_PIP_LOCATION" ]; then
46 HORIZON_PIP_LOCATION="git+https://git.openstack.org/openstack/horizon@$BRANCH_NAME#egg=horizon"
47 fi
48 $install_cmd -U -e ${HORIZON_PIP_LOCATION}
49fi
50
51$install_cmd -U $*
52exit $?
diff --git a/tools/tox_install.sh b/tools/tox_install.sh
new file mode 100755
index 0000000..ebb8315
--- /dev/null
+++ b/tools/tox_install.sh
@@ -0,0 +1,65 @@
1#!/usr/bin/env bash
2
3# Many of horizon's repos suffer from the problem of depending on horizon,
4# but it not existing on pypi.
5
6# This wrapper for tox's package installer will use the existing package
7# if it exists, else use zuul-cloner if that program exists, else grab it
8# from horizon master via a hard-coded URL. That last case should only
9# happen with devs running unit tests locally.
10
11# From the tox.ini config page:
12# install_command=ARGV
13# default:
14# pip install {opts} {packages}
15
16ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
17BRANCH_NAME=master
18GIT_BASE=${GIT_BASE:-https://git.openstack.org/}
19
20install_project() {
21 local project=$1
22 local branch=${2:-$BRANCH_NAME}
23 local module_name=${project//-/_}
24
25 set +e
26 project_installed=$(echo "import $module_name" | python 2>/dev/null ; echo $?)
27 set -e
28
29 if [ $project_installed -eq 0 ]; then
30 echo "ALREADY INSTALLED" > /tmp/tox_install.txt
31 echo "$project already installed; using existing package"
32 elif [ -x "$ZUUL_CLONER" ]; then
33 echo "ZUUL CLONER" > /tmp/tox_install.txt
34 # Make this relative to current working directory so that
35 # git clean can remove it. We cannot remove the directory directly
36 # since it is referenced after $install_cmd -e
37 mkdir -p .tmp
38 PROJECT_DIR=$(/bin/mktemp -d -p $(pwd)/.tmp)
39 pushd $PROJECT_DIR
40 $ZUUL_CLONER --cache-dir \
41 /opt/git \
42 --branch $branch \
43 http://git.openstack.org \
44 openstack/$project
45 cd openstack/$project
46 $install_cmd -e .
47 popd
48 else
49 echo "PIP HARDCODE" > /tmp/tox_install.txt
50 local GIT_REPO="$GIT_BASE/openstack/$project"
51 SRC_DIR="$VIRTUAL_ENV/src/$project"
52 git clone --depth 1 --branch $branch $GIT_REPO $SRC_DIR
53 $install_cmd -U -e $SRC_DIR
54 fi
55}
56
57set -e
58
59install_cmd="pip install -c$1"
60shift
61
62install_project horizon
63
64$install_cmd -U $*
65exit $?
diff --git a/tox.ini b/tox.ini
index 40c66ca..c9a13b1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,8 +5,8 @@ skipsdist = True
5 5
6[testenv] 6[testenv]
7usedevelop = True 7usedevelop = True
8install_command = {toxinidir}/tools/pip_install.sh \ 8install_command = {toxinidir}/tools/tox_install.sh \
9 -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} \ 9 {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} \
10 {opts} {packages} 10 {opts} {packages}
11setenv = 11setenv =
12 VIRTUAL_ENV={envdir} 12 VIRTUAL_ENV={envdir}
@@ -100,7 +100,7 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen
100local-check-factory = horizon.hacking.checks.factory 100local-check-factory = horizon.hacking.checks.factory
101 101
102[flake8] 102[flake8]
103exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules 103exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,.tmp
104max-complexity = 20 104max-complexity = 20
105import-order-style = pep8 105import-order-style = pep8
106 106