|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
| 3 | +unset PYENV_VERSION |
| 4 | + |
3 | 5 | if [[ ! -d $PYENV_ROOT ]] |
4 | 6 | then |
5 | 7 | export PYENV_ROOT="$HOME/.pyenv" |
|
12 | 14 | exit 1 |
13 | 15 | fi |
14 | 16 |
|
| 17 | +rm -f $PROJDIR/.python-version |
| 18 | + |
15 | 19 | # Install pyenv if it's missing |
16 | 20 | if [[ ! -d $PYENV_ROOT ]] |
17 | 21 | then |
18 | | - git clone https://github.com/yyuu/pyenv.git $PYENV_ROOT |
| 22 | + git clone 'https://github.com/yyuu/pyenv.git' $PYENV_ROOT |
19 | 23 | else |
20 | 24 | (cd $PYENV_ROOT && git fetch --all) |
21 | 25 | fi |
|
25 | 29 | declare -r pyenv_virtualenv_dir="$PYENV_ROOT/plugins/pyenv-virtualenv" |
26 | 30 | if [[ ! -d $pyenv_virtualenv_dir ]] |
27 | 31 | 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 |
29 | 33 | else |
30 | 34 | (cd $pyenv_virtualenv_dir && git fetch --all) |
31 | 35 | fi |
|
35 | 39 | declare -r pyenv_alias_dir="$PYENV_ROOT/plugins/pyenv-alias" |
36 | 40 | if [[ ! -d $pyenv_alias_dir ]] |
37 | 41 | 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 |
39 | 43 | else |
40 | 44 | (cd $pyenv_alias_dir && git pull origin master) |
41 | 45 | fi |
|
55 | 59 | eval "$(pyenv virtualenv-init -)" |
56 | 60 | fi |
57 | 61 |
|
| 62 | +do_pip_upgrades='false' |
| 63 | + |
58 | 64 | # NB: 2.7.8 is special-cased |
59 | 65 | for pyver in 2.7 3.3 3.4 3.5 |
60 | 66 | 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" |
62 | 69 | then |
| 70 | + # Need to install it |
| 71 | + do_pip_upgrades='true' |
| 72 | + |
63 | 73 | declare -i pymaj="${pyver%.*}" |
64 | 74 | declare -i pymin="${pyver#*.}" |
65 | 75 | pyver_latest="$(pyenv install --list | grep -E "^[[:space:]]+$pymaj\\.$pymin\\.[[:digit:]]+\$" | tail -n1 | sed -e 's/[[:space:]]//g')" |
66 | 76 |
|
67 | 77 | 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" |
71 | 80 | fi |
72 | 81 | done |
73 | 82 |
|
74 | 83 | if ! pyenv versions | fgrep -q 'riak_2.7.8' |
75 | 84 | then |
| 85 | + # Need to install it |
| 86 | + do_pip_upgrades='true' |
| 87 | + |
76 | 88 | echo "[INFO] installing Python 2.7.8" |
77 | 89 | VERSION_ALIAS='riak_2.7.8' pyenv install '2.7.8' |
78 | 90 | pyenv virtualenv 'riak_2.7.8' 'riak-py278' |
79 | 91 | fi |
80 | 92 |
|
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 |
82 | 95 |
|
83 | | -pyenv versions |
| 96 | +pyenv rehash |
84 | 97 |
|
85 | | -if [[ $(python --version) == Python\ 3.* ]] |
| 98 | +if [[ $do_pip_upgrades == 'true' ]] |
86 | 99 | 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_') |
89 | 101 | 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 |
99 | 104 | 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 |
100 | 117 | pyenv rehash |
101 | 118 | else |
102 | 119 | echo "[ERROR] expected Python 3 to be 'python' at this point" 1>&2 |
| 120 | + popd |
103 | 121 | exit 1 |
104 | 122 | fi |
| 123 | + |
| 124 | +popd |
0 commit comments