Skip to content

Commit 6b3dd9e

Browse files
committed
Merge pull request #463 from basho/fixes/lrb/test-clean-gh-460
READY: Improvement in pyenv setup, tox setup
2 parents 1748616 + 89f4dfb commit 6b3dd9e

File tree

5 files changed

+144
-41
lines changed

5 files changed

+144
-41
lines changed

buildbot/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ preconfigure:
1818
configure:
1919
$(TOOLS_DIR)/riak-cluster-config $(RIAK_ADMIN) 8098 true true
2020

21-
configure_timeseries:
22-
@../setup.py setup_timeseries --riak-admin=$(RIAK_ADMIN)
23-
2421
compile:
2522
@echo NO-OP
2623

buildbot/clean-env

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
3+
set -o nounset
4+
set -o errexit
5+
6+
function now
7+
{
8+
date '+%Y-%m-%d %H:%M:%S'
9+
}
10+
11+
function perr
12+
{
13+
echo "$(now) [error]: $@" 1>&2
14+
}
15+
16+
function pinfo
17+
{
18+
echo "$(now) [info]: $@"
19+
}
20+
21+
function errexit
22+
{
23+
perr "$@"
24+
exit 1
25+
}
26+
27+
function clean_venvs
28+
{
29+
for VENV in $(pyenv virtualenvs | awk '/^[[:space:]]*riak-/ { print $1 }')
30+
do
31+
pinfo Uninstalling virtualenv "$VENV"
32+
pyenv uninstall --force "$VENV"
33+
done
34+
}
35+
36+
function clean_pythons
37+
{
38+
for RPY in $(pyenv versions | awk '/^[[:space:]]*riak_/ { print $1 }')
39+
do
40+
pinfo Uninstalling python "$RPY"
41+
pyenv uninstall --force "$RPY"
42+
done
43+
}
44+
45+
function clean_tox
46+
{
47+
if [[ -d ./.tox ]]
48+
then
49+
pinfo Removing ./.tox
50+
rm -rf ./.tox
51+
fi
52+
}
53+
54+
function usage
55+
{
56+
echo "
57+
clean-env: Clean up your pyenv
58+
59+
Usage:
60+
61+
clean-env [-p] [-t] [-v]
62+
63+
-p Clean up Riak-specific Python versions
64+
-t Clean up tox
65+
-v Clean up Riak-specific virtualenvs
66+
"
67+
exit 0
68+
}
69+
70+
opt_clean_pythons='false'
71+
opt_clean_venvs='false'
72+
opt_clean_tox='false'
73+
74+
while getopts 'ptv' opt; do
75+
case $opt in
76+
p)
77+
opt_clean_pythons='true';;
78+
t)
79+
opt_clean_tox='true';;
80+
v)
81+
opt_clean_venvs='true';;
82+
*)
83+
usage;;
84+
esac
85+
done
86+
87+
if [[ $opt_clean_venvs == 'true' ]]
88+
then
89+
clean_venvs
90+
fi
91+
92+
if [[ $opt_clean_pythons == 'true' ]]
93+
then
94+
clean_pythons
95+
fi
96+
97+
if [[ $opt_clean_tox == 'true' ]]
98+
then
99+
clean_tox
100+
fi

buildbot/tox_cleanup.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

buildbot/tox_setup.sh

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
unset PYENV_VERSION
4+
35
if [[ ! -d $PYENV_ROOT ]]
46
then
57
export PYENV_ROOT="$HOME/.pyenv"
@@ -12,10 +14,12 @@ then
1214
exit 1
1315
fi
1416

17+
rm -f $PROJDIR/.python-version
18+
1519
# Install pyenv if it's missing
1620
if [[ ! -d $PYENV_ROOT ]]
1721
then
18-
git clone https://github.com/yyuu/pyenv.git $PYENV_ROOT
22+
git clone 'https://github.com/yyuu/pyenv.git' $PYENV_ROOT
1923
else
2024
(cd $PYENV_ROOT && git fetch --all)
2125
fi
@@ -25,7 +29,7 @@ fi
2529
declare -r pyenv_virtualenv_dir="$PYENV_ROOT/plugins/pyenv-virtualenv"
2630
if [[ ! -d $pyenv_virtualenv_dir ]]
2731
then
28-
git clone https://github.com/yyuu/pyenv-virtualenv.git $pyenv_virtualenv_dir
32+
git clone 'https://github.com/yyuu/pyenv-virtualenv.git' $pyenv_virtualenv_dir
2933
else
3034
(cd $pyenv_virtualenv_dir && git fetch --all)
3135
fi
@@ -35,7 +39,7 @@ fi
3539
declare -r pyenv_alias_dir="$PYENV_ROOT/plugins/pyenv-alias"
3640
if [[ ! -d $pyenv_alias_dir ]]
3741
then
38-
git clone https://github.com/s1341/pyenv-alias.git $pyenv_alias_dir
42+
git clone 'https://github.com/s1341/pyenv-alias.git' $pyenv_alias_dir
3943
else
4044
(cd $pyenv_alias_dir && git pull origin master)
4145
fi
@@ -55,50 +59,66 @@ then
5559
eval "$(pyenv virtualenv-init -)"
5660
fi
5761

62+
do_pip_upgrades='false'
63+
5864
# NB: 2.7.8 is special-cased
5965
for pyver in 2.7 3.3 3.4 3.5
6066
do
61-
if ! pyenv versions | fgrep -v 'riak_2.7.8' | fgrep -q "riak_$pyver"
67+
riak_py_alias="riak_$pyver"
68+
if ! pyenv versions | fgrep -v 'riak_2.7.8' | fgrep -q "$riak_py_alias"
6269
then
70+
# Need to install it
71+
do_pip_upgrades='true'
72+
6373
declare -i pymaj="${pyver%.*}"
6474
declare -i pymin="${pyver#*.}"
6575
pyver_latest="$(pyenv install --list | grep -E "^[[:space:]]+$pymaj\\.$pymin\\.[[:digit:]]+\$" | tail -n1 | sed -e 's/[[:space:]]//g')"
6676

6777
echo "[INFO] installing Python $pyver_latest"
68-
riak_pyver="riak_$pyver_latest"
69-
VERSION_ALIAS="$riak_pyver" pyenv install "$pyver_latest"
70-
pyenv virtualenv "$riak_pyver" "riak-py$pymaj$pymin"
78+
VERSION_ALIAS="$riak_py_alias" pyenv install "$pyver_latest"
79+
pyenv virtualenv "$riak_py_alias" "riak-py$pymaj$pymin"
7180
fi
7281
done
7382

7483
if ! pyenv versions | fgrep -q 'riak_2.7.8'
7584
then
85+
# Need to install it
86+
do_pip_upgrades='true'
87+
7688
echo "[INFO] installing Python 2.7.8"
7789
VERSION_ALIAS='riak_2.7.8' pyenv install '2.7.8'
7890
pyenv virtualenv 'riak_2.7.8' 'riak-py278'
7991
fi
8092

81-
(cd $PROJDIR && pyenv local riak-py35 riak-py34 riak-py33 riak-py27 riak-py278)
93+
pushd $PROJDIR
94+
pyenv local riak-py35 riak-py34 riak-py33 riak-py27 riak-py278
8295

83-
pyenv versions
96+
pyenv rehash
8497

85-
if [[ $(python --version) == Python\ 3.* ]]
98+
if [[ $do_pip_upgrades == 'true' ]]
8699
then
87-
pip install --upgrade pip
88-
for module in six tox python3-protobuf
100+
for PY in $(pyenv versions --bare --skip-aliases | grep '^riak_')
89101
do
90-
if ! pip show --quiet $module
91-
then
92-
pip install --ignore-installed $module
93-
if ! pip show --quiet $module
94-
then
95-
echo "[ERROR] install of $module failed" 1>&2
96-
exit 1
97-
fi
98-
fi
102+
echo "[INFO] $PY - upgrading pip / setuptools"
103+
PYENV_VERSION="$PY" pip install --upgrade pip setuptools
99104
done
105+
fi
106+
107+
python_version="$(python --version)"
108+
if [[ $python_version == Python\ 3* ]]
109+
then
110+
pip install --ignore-installed tox
111+
if ! pip show --quiet tox
112+
then
113+
echo "[ERROR] install of 'tox' failed" 1>&2
114+
popd
115+
exit 1
116+
fi
100117
pyenv rehash
101118
else
102119
echo "[ERROR] expected Python 3 to be 'python' at this point" 1>&2
120+
popd
103121
exit 1
104122
fi
123+
124+
popd

tox.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py278, py27, py33, py34, py35
7+
envlist = riak-py278, riak-py27, riak-py33, riak-py34, riak-py35
88

9-
[testenv:py278]
9+
[testenv:riak-py278]
1010
basepython = {env:HOME}/.pyenv/versions/riak-py278/bin/python2.7
1111

1212
[testenv]
1313
install_command = pip install --upgrade {packages}
1414
commands = {envpython} setup.py test
15-
deps = six
16-
pip
15+
deps = pip
1716
passenv = RUN_* SKIP_* RIAK_*

0 commit comments

Comments
 (0)