-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpycompiler.bash
56 lines (43 loc) · 1.27 KB
/
pycompiler.bash
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
#!/usr/bin/env bash
: <<'!COMMENT'
GGCOM - Docker - pyenv v201508130219
Louis T. Getterman IV (@LTGIV)
www.GotGetLLC.com | www.opensour.cc/ggcom/docker/pyenv
Example usage of compile+install, and subsequent test of desired version:
$] pycompiler.bash VERSION
$] python --version
!COMMENT
target=$(echo "$1" | tr -d '[[:space:]]')
destination=${2-''}
rexp='^TARGET\.[0-9][\.0-9]*$'
pylist=$( pyenv install --list )
echo "----------"
echo "$pylist"
echo "----------"
if [ "${#target}" == 1 ] || [ "$target" == "latest" ] || [ -z "$target" ]; then
case $target in
[2-3]*)
pyrexo="${rexp/TARGET/$target}";;
*)
pyrexo="${rexp/TARGET/[0-9]}";;
esac
if [ -z "$target" ]; then
echo "You can select a specific version by editing the 'version' file that's in your Dockerfile directory."
echo "----------"
fi
pyver=$( echo "$pylist" | sed -e 's/^[[:space:]]*//' | grep --regexp $pyrexo | sort --version-sort | tail -n 1 )
else
pyver=$target
fi
unset target rexp pylist pyrexo
echo "Installing Python $pyver, and setting as global Python interpreter:"
pyenv install $pyver
pyenv global $pyver
pip install --upgrade pip
if [ ! -z "$destination" ]; then
pyenv virtualenv "$pyver" "$destination"
pyenv global "$destination"
pip install --upgrade pip
fi
unset pyver
pyenv rehash