|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Client constraint file contains this client version pin that is in conflict |
| 4 | +# with installing the client from source. We should replace the version pin in |
| 5 | +# the constraints file before applying it for from-source installation. |
| 6 | + |
| 7 | +ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner |
| 8 | +BRANCH_NAME=master |
| 9 | +CLIENT_NAME=python-openstackclient |
| 10 | +requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?) |
| 11 | + |
| 12 | +set -e |
| 13 | + |
| 14 | +CONSTRAINTS_FILE=$1 |
| 15 | +shift |
| 16 | + |
| 17 | +install_cmd="pip install" |
| 18 | +if [ $CONSTRAINTS_FILE != "unconstrained" ]; then |
| 19 | + |
| 20 | + mydir=$(mktemp -dt "$CLIENT_NAME-tox_install-XXXXXXX") |
| 21 | + localfile=$mydir/upper-constraints.txt |
| 22 | + if [[ $CONSTRAINTS_FILE != http* ]]; then |
| 23 | + CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE |
| 24 | + fi |
| 25 | + curl $CONSTRAINTS_FILE -k -o $localfile |
| 26 | + install_cmd="$install_cmd -c$localfile" |
| 27 | + |
| 28 | + if [ $requirements_installed -eq 0 ]; then |
| 29 | + echo "ALREADY INSTALLED" > /tmp/tox_install.txt |
| 30 | + echo "Requirements already installed; using existing package" |
| 31 | + elif [ -x "$ZUUL_CLONER" ]; then |
| 32 | + export ZUUL_BRANCH=${ZUUL_BRANCH-$BRANCH} |
| 33 | + echo "ZUUL CLONER" > /tmp/tox_install.txt |
| 34 | + pushd $mydir |
| 35 | + $ZUUL_CLONER --cache-dir \ |
| 36 | + /opt/git \ |
| 37 | + --branch $BRANCH_NAME \ |
| 38 | + git://git.openstack.org \ |
| 39 | + openstack/requirements |
| 40 | + cd openstack/requirements |
| 41 | + $install_cmd -e . |
| 42 | + popd |
| 43 | + else |
| 44 | + echo "PIP HARDCODE" > /tmp/tox_install.txt |
| 45 | + if [ -z "$REQUIREMENTS_PIP_LOCATION" ]; then |
| 46 | + REQUIREMENTS_PIP_LOCATION="git+https://git.openstack.org/openstack/requirements@$BRANCH_NAME#egg=requirements" |
| 47 | + fi |
| 48 | + $install_cmd -U -e ${REQUIREMENTS_PIP_LOCATION} |
| 49 | + fi |
| 50 | + |
| 51 | + edit-constraints $localfile -- $CLIENT_NAME "-e file://$PWD#egg=$CLIENT_NAME" |
| 52 | +fi |
| 53 | + |
| 54 | +$install_cmd -U $* |
| 55 | +exit $? |
0 commit comments