File
Blob: tools/unix/find-python3.sh
| 1 | |
| 2 | get_python3() { |
| 3 | # Search for python3 |
| 4 | python=$(which python3 2>/dev/null) |
| 5 | |
| 6 | # If not found, search for python |
| 7 | if [ -z "$python" ]; then |
| 8 | python=$(which python 2>/dev/null) |
| 9 | if [ -n "$python" ]; then |
| 10 | local python_version=$($python -V 2>&1 | head -n 1 | cut -d ' ' -f 2- | cut -d '.' -f1) |
| 11 | if [ "$python_version" != "3" ]; then |
| 12 | unset python |
| 13 | fi |
| 14 | fi |
| 15 | fi |
| 16 | |
| 17 | if [ -z "$python" ]; then |
| 18 | return |
| 19 | fi |
| 20 | echo "$python" |
| 21 | } |