-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·60 lines (49 loc) · 1.46 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·60 lines (49 loc) · 1.46 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
#!/usr/bin/env zsh
set -e
set -o pipefail
# Import our common helper scripts
source "${ZSH}/lib/_helpers"
echo "[python::install]"
source "${ZSH}/python/python-versions.zsh"
# Note: you can also install the latest head release with: brew unlink pyenv && brew install pyenv --head
require_installed_brew "pyenv"
require_installed_brew "pyenv-virtualenv"
install_python_version() {
local version_series="$1"
local version="$2"
if [[ -z "$version" ]]; then
echo " [pyenv] Python ${version_series} version is disabled; skipping."
return
fi
if pyenv versions --bare | grep -Fxq -- "$version"; then
echo " [pyenv] Python $version already installed."
else
echo " [pyenv] Installing python $version for you.."
pyenv install "$version"
pyenv rehash
fi
if [[ "$PYTHON_GLOBAL_VER" == "$version_series" ]]; then
echo " [pyenv] Setting python $version as global.."
pyenv global "$version"
fi
}
case "$PYTHON_GLOBAL_VER" in
2x)
if [[ -z "$PYTHON_2X_VER" ]]; then
echo " [pyenv] Error: PYTHON_GLOBAL_VER is 2x, but PYTHON_2X_VER is disabled." >&2
exit 1
fi
;;
3x)
if [[ -z "$PYTHON_3X_VER" ]]; then
echo " [pyenv] Error: PYTHON_GLOBAL_VER is 3x, but PYTHON_3X_VER is disabled." >&2
exit 1
fi
;;
*)
echo " [pyenv] Error: PYTHON_GLOBAL_VER must be either 2x or 3x." >&2
exit 1
;;
esac
install_python_version "2x" "$PYTHON_2X_VER"
install_python_version "3x" "$PYTHON_3X_VER"