-
Notifications
You must be signed in to change notification settings - Fork 4
/
tim
executable file
·48 lines (42 loc) · 1.21 KB
/
tim
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
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Check that Python 3 is installed
# Python 3 executable can be named differently depending on the OS
# Possible names
# - python3
# - python3.6
# - python
# - py
#
# Additionally allow PYTHON_CMD env var to be set
names_to_check=(
"$PYTHON_CMD"
"py"
"python"
"python3"
"python3.6"
)
function check_python3_installed() {
for name in "${names_to_check[@]}"; do
if command -v "$name" --version > /dev/null 2>&1; then
version=$("$name" --version 2>&1 | cut -d ' ' -f 2)
version_major=$(echo "$version" | cut -d '.' -f 1)
version_minor=$(echo "$version" | cut -d '.' -f 2)
if [ "$version_major" -ge 3 ] && [ "$version_minor" -ge 6 ]; then
python_cmd="$name"
return 0
fi
fi
done
return 1
}
if ! check_python3_installed; then
echo "Python 3.6 was not found in PATH. Install Python 3 (https://www.python.org/downloads/) and try again."
exit 1
fi
# Ensure the cwd is the location of this script
# Call cli/tim.py passing all arguments (skip the first one)
(
cd "$DIR"
"$python_cmd" -m cli.tim "${@:1}"
)