forked from basho/riak-python-client
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpyenv-setup
More file actions
executable file
·101 lines (83 loc) · 2.36 KB
/
Copy pathpyenv-setup
File metadata and controls
executable file
·101 lines (83 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
unset PYENV_VERSION
if [[ ! -d $PYENV_ROOT ]]
then
export PYENV_ROOT="$HOME/.pyenv"
fi
declare -r PROJDIR="$PWD"
if [[ ! -s $PROJDIR/riak/__init__.py ]]
then
echo "[ERROR] script must be run from the clone of github.com/basho/riak-python-client" 1>&2
exit 1
fi
rm -f $PROJDIR/.python-version
# Install pyenv if it's missing
if [[ ! -d $PYENV_ROOT ]]
then
git clone 'https://github.com/yyuu/pyenv.git' $PYENV_ROOT
else
(cd $PYENV_ROOT && git fetch --all)
fi
(cd $PYENV_ROOT && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))
declare -r pyenv_alias_dir="$PYENV_ROOT/plugins/pyenv-alias"
if [[ ! -d $pyenv_alias_dir ]]
then
git clone 'https://github.com/s1341/pyenv-alias.git' $pyenv_alias_dir
else
(cd $pyenv_alias_dir && git pull origin master)
fi
# Add pyenv root to PATH
# and initialize pyenv
if [[ $PATH != */.pyenv* ]]
then
echo "[INFO] adding $PYENV_ROOT/bin to PATH"
export PATH="$PYENV_ROOT/bin:$PATH"
fi
if [[ $(type -t pyenv) != 'function' ]]
then
echo "[INFO] init pyenv"
eval "$(pyenv init -)"
fi
do_pip_upgrades='false'
for pyver in 3.3 3.4 3.5 3.6 3.7 3.8
do
riak_py_alias="riak_$pyver"
if ! pyenv versions | fgrep -q "$riak_py_alias"
then
# Need to install it
do_pip_upgrades='true'
declare -i pymaj="${pyver%.*}"
declare -i pymin="${pyver#*.}"
pyver_latest="$(pyenv install --list | grep -E "^[[:space:]]+$pymaj\\.$pymin\\.[[:digit:]]+\$" | tail -n1 | sed -e 's/[[:space:]]//g')"
echo "[INFO] installing Python $pyver_latest"
VERSION_ALIAS="$riak_py_alias" pyenv install "$pyver_latest"
fi
done
pushd $PROJDIR
pyenv local 'riak_3.8' 'riak_3.7' 'riak_3.6' 'riak_3.5' 'riak_3.4' 'riak_3.3'
pyenv rehash
if [[ $do_pip_upgrades == 'true' ]]
then
for PY in $(pyenv versions --bare --skip-aliases | grep '^riak_')
do
echo "[INFO] $PY - upgrading pip / setuptools"
PYENV_VERSION="$PY" pip install --upgrade pip setuptools
done
fi
python_version="$(python --version)"
if [[ $python_version == Python\ 3* ]]
then
pip install --ignore-installed tox
if ! pip show --quiet tox
then
echo "[ERROR] install of 'tox' failed" 1>&2
popd
exit 1
fi
pyenv rehash
else
echo "[ERROR] expected Python 3 to be 'python' at this point" 1>&2
popd
exit 1
fi
popd