Merge "Fix installing horizon dependency"

This commit is contained in:
Zuul 2018-02-05 13:09:09 +00:00 committed by Gerrit Code Review
commit cf2bbf32cb
2 changed files with 58 additions and 49 deletions

View File

@ -1,56 +1,64 @@
#!/usr/bin/env bash
# Constraint file contains this package version pin that is in conflict
# with installing the package from source. We should replace the version pin in
# the constraints file before applying it for from-source installation.
# 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
PACKAGE_NAME=monasca-ui
requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?)
GIT_BASE=${GIT_BASE:-https://git.openstack.org/}
install_project() {
local project=$1
local branch=${2:-$BRANCH_NAME}
local module_name=${project//-/_}
set +e
project_installed=$(echo "import $module_name" | python 2>/dev/null ; echo $?)
set -e
if [ $project_installed -eq 0 ]; then
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
echo "$project already installed; using existing package"
elif [ -x "$ZUUL_CLONER" ]; then
echo "ZUUL CLONER" > /tmp/tox_install.txt
# Make this relative to current working directory so that
# git clean can remove it. We cannot remove the directory directly
# since it is referenced after $install_cmd -e
mkdir -p .tmp
PROJECT_DIR=$(/bin/mktemp -d -p $(pwd)/.tmp)
pushd $PROJECT_DIR
$ZUUL_CLONER --cache-dir \
/opt/git \
--branch $branch \
http://git.openstack.org \
openstack/$project
cd openstack/$project
$install_cmd -e .
popd
else
echo "PIP HARDCODE" > /tmp/tox_install.txt
local GIT_REPO="$GIT_BASE/openstack/$project"
SRC_DIR="$VIRTUAL_ENV/src/$project"
git clone --depth 1 --branch $branch $GIT_REPO $SRC_DIR
$install_cmd -U -e $SRC_DIR
fi
}
set -e
git config --global url.https://git.openstack.org/.insteadOf git://git.openstack.org/
CONSTRAINTS_FILE=$1
install_cmd="pip install -c$1"
shift
install_cmd="pip install"
mydir=$(mktemp -dt "$PACKAGE_NAME-tox_install-XXXXXXX")
trap "rm -rf $mydir" EXIT
localfile=$mydir/upper-constraints.txt
if [[ $CONSTRAINTS_FILE != http* ]]; then
CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE
fi
curl $CONSTRAINTS_FILE -k -o $localfile
install_cmd="$install_cmd -c$localfile"
if [ $requirements_installed -eq 0 ]; then
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
echo "Requirements already installed; using existing package"
elif [ -x "$ZUUL_CLONER" ]; then
echo "ZUUL CLONER" > /tmp/tox_install.txt
pushd $mydir
$ZUUL_CLONER --cache-dir \
/opt/git \
--branch $BRANCH_NAME \
git://git.openstack.org \
openstack/requirements
cd openstack/requirements ; $install_cmd -e . ; cd -
popd
else
echo "PIP HARDCODE" > /tmp/tox_install.txt
if [ -z "$REQUIREMENTS_PIP_LOCATION" ]; then
REQUIREMENTS_PIP_LOCATION="git+https://git.openstack.org/openstack/requirements@$BRANCH_NAME#egg=requirements"
fi
$install_cmd -U -e ${REQUIREMENTS_PIP_LOCATION}
fi
# This is the main purpose of the script: Allow local installation of
# the current repo. It is listed in constraints file and thus any
# install will be constrained and we need to unconstrain it.
edit-constraints $localfile -- $PACKAGE_NAME "-e file://$PWD#egg=$PACKAGE_NAME"
install_project horizon
$install_cmd -U $*
exit $?

11
tox.ini
View File

@ -15,11 +15,12 @@ passenv = http_proxy
HTTPS_PROXY
no_proxy
NO_PROXY
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon
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
install_command = {toxinidir}/tools/tox_install.sh \
{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} \
{opts} {packages}
whitelist_externals =
/bin/bash
find