-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
54 lines (44 loc) · 2.12 KB
/
update.sh
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
#!/bin/bash
# Ensure we're in the MusicBot directory
cd "$(dirname "$BASH_SOURCE")"
# Set variables for python versions. Could probably be done cleaner, but this works.
declare -A python=( ["0"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[0]))' || { echo "no py"; }` ["1"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py"; }` ["2"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py"; }` )
declare -A python3=( ["0"]=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py3"; }` ["1"]=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py3"; }` )
PYTHON35_VERSION=`python3.5 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py35"; }`
PYTHON36_VERSION=`python3.6 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py36"; }`
PYTHON37_VERSION=`python3.7 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py37"; }`
if [ "${python[0]}" -eq "3" ]; then # Python = 3
if [ "${python[1]}" -eq "5" ]; then # Python = 3.5
if [ "${python[2]}" -ge "3" ]; then # Python = 3.5.3
python update.py
exit
fi
elif [ "${python[1]}" -ge "6" ]; then # Python >= 3.6
python update.py
exit
fi
fi
if [ "${python3[0]}" -eq "5" ]; then # Python3 = 3.5
if [ "${python3[1]}" -ge "3" ]; then # Python3 >= 3.5.3
python3 update.py
exit
fi
fi
if [ "${python3[0]}" -ge "6" ]; then # Python3 >= 3.6
python3 update.py
exit
fi
if [ "$PYTHON35_VERSION" -ge "3" ]; then # Python3.5 > 3.5.3
python3.5 update.py
exit
fi
if [ "$PYTHON36_VERSION" -eq "6" ]; then # Python3.6 = 3.6
python3.6 update.py
exit
fi
if [ "$PYTHON37_VERSION" -eq "7" ]; then # Python3.7 = 3.7
python3.7 update.py
exit
fi
echo "You are running an unsupported Python version."
echo "Please use a version of Python above 3.5.2."