-
Notifications
You must be signed in to change notification settings - Fork 52
/
python
44 lines (38 loc) · 1.05 KB
/
python
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
#!/usr/bin/env bash
PY_MIRROR="https://www.python.org"
# Output lists of versions
plug_list_versions() {
echo $(curl -s "$PY_MIRROR/downloads/" | grep "release-number" | \
grep -E -o '\s[0-9]+\.[0-9]+\.[0-9]+')
}
# Return full url for tarball for download
plug_url_for_download() {
local version=$1
echo "$PY_MIRROR/ftp/python/$version/Python-$version.tgz"
}
plug_install_python_symlink() {
local env_name=$1
local env_name_full=$2
if [ ! -f "$env_name_full/bin/python" ]; then
(
cd "$env_name_full/bin"
ln -s `find . -iname "python?"` python
)
fi
}
plug_install_pip() {
local env_name=$1
local env_name_full=$2
if [ ! -f "$env_name_full/bin/pip" ]; then
(
nv on --same-shell $env_name >/dev/null
local get_pip_url="https://bootstrap.pypa.io/get-pip.py"
local get_pip=$(nv_download_file $get_pip_url "get-pip.py")
python $get_pip >/dev/null
)
fi
}
plug_post_install_actions() {
plug_install_python_symlink "$@"
plug_install_pip "$@"
}