Skip to content

Commit bdb475d

Browse files
committed
Sync tools/tox_install.sh
Sync tools/tox_install.sh with python-openstackclient. This brings in the following improvements: * Do not leave temporary directory around, instead delete temporary directory directly after usage (change I939eae82dba3287fd4e4086128ebf4609a0e0770). * Do not set ZUUL_BRANCH explicitely and remove unused if condition (change I0077c986a17d6bb92791474e03d1e77776e9382f). Change-Id: Ie56634fcb4dcf670510771efffccb4214c87359c (cherry picked from commit e27a1c9)
1 parent 573c438 commit bdb475d

1 file changed

Lines changed: 42 additions & 15 deletions

File tree

tools/tox_install.sh

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,57 @@
11
#!/usr/bin/env bash
22

3-
# Client constraint file contains this client version pin that is in conflict
4-
# with installing the client from source. We should remove the version pin in
3+
# Constraint file contains this package version pin that is in conflict
4+
# with installing the package from source. We should replace the version pin in
55
# the constraints file before applying it for from-source installation.
66

7-
CONSTRAINTS_FILE="$1"
8-
shift 1
7+
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
8+
BRANCH_NAME=stable/ocata
9+
PACKAGE_NAME=monasca-ui
10+
requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?)
911

1012
set -e
1113

12-
# NOTE(tonyb): Place this in the tox enviroment's log dir so it will get
13-
# published to logs.openstack.org for easy debugging.
14-
localfile="$VIRTUAL_ENV/log/upper-constraints.txt"
14+
git config --global url.https://git.openstack.org/.insteadOf git://git.openstack.org/
1515

16-
if [[ "$CONSTRAINTS_FILE" != http* ]]; then
17-
CONSTRAINTS_FILE="file://$CONSTRAINTS_FILE"
18-
fi
19-
# NOTE(tonyb): need to add curl to bindep.txt if the project supports bindep
20-
curl "$CONSTRAINTS_FILE" --insecure --progress-bar --output "$localfile"
16+
CONSTRAINTS_FILE=$1
17+
shift
2118

22-
pip install -c"$localfile" openstack-requirements
19+
install_cmd="pip install"
20+
mydir=$(mktemp -dt "$PACKAGE_NAME-tox_install-XXXXXXX")
21+
trap "rm -rf $mydir" EXIT
22+
localfile=$mydir/upper-constraints.txt
23+
if [[ $CONSTRAINTS_FILE != http* ]]; then
24+
CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE
25+
fi
26+
curl $CONSTRAINTS_FILE -k -o $localfile
27+
install_cmd="$install_cmd -c$localfile"
28+
29+
if [ $requirements_installed -eq 0 ]; then
30+
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
31+
echo "Requirements already installed; using existing package"
32+
elif [ -x "$ZUUL_CLONER" ]; then
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
2350

2451
# This is the main purpose of the script: Allow local installation of
2552
# the current repo. It is listed in constraints file and thus any
2653
# install will be constrained and we need to unconstrain it.
27-
edit-constraints "$localfile" -- "$CLIENT_NAME"
54+
edit-constraints $localfile -- $PACKAGE_NAME "-e file://$PWD#egg=$PACKAGE_NAME"
2855

29-
pip install -c"$localfile" -U "$@"
56+
$install_cmd -U $*
3057
exit $?

0 commit comments

Comments
 (0)