File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22me=$( basename " $0 " )
33
4+ is_python3 () {
5+ " $@ " -c ' import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' > /dev/null 2>&1
6+ }
7+
48case " $OSTYPE " in
59 msys* |mingw* |cygwin* |win32* )
610 echo " Running ${me} on Windows"
7- if command -v python3 > /dev/null 2>&1 ; then
8- PYTHON_EXECUTABLE=(python3)
9- elif command -v python > /dev/null 2>&1 ; then
10- PYTHON_EXECUTABLE=(python)
11+ if command -v py > /dev/null 2>&1 && is_python3 py -3; then
12+ PYTHON_EXECUTABLE=(py -3)
1113 else
12- echo " Error: Python not found or not runnable"
13- exit 1
14+ python3_path=$( command -v python3 2> /dev/null || true)
15+ if [ -n " $python3_path " ] && [[ " $python3_path " != * WindowsApps* ]] && is_python3 python3; then
16+ PYTHON_EXECUTABLE=(python3)
17+ elif command -v python > /dev/null 2>&1 && is_python3 python; then
18+ PYTHON_EXECUTABLE=(python)
19+ else
20+ echo " Error: Python 3 not found. Please install Python 3 or disable the Microsoft Store python alias."
21+ exit 1
22+ fi
1423 fi
1524 ;;
1625 * )
1726 echo " Running ${me} on linux / mac / unix"
18- if command -v python3 > /dev/null 2>&1 ; then
27+ if command -v python3 > /dev/null 2>&1 && is_python3 python3 ; then
1928 PYTHON_EXECUTABLE=(python3)
20- elif command -v python > /dev/null 2>&1 ; then
29+ elif command -v python > /dev/null 2>&1 && is_python3 python ; then
2130 PYTHON_EXECUTABLE=(python)
2231 else
2332 echo " Error: Python not found or not runnable"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22me=$( basename " $0 " )
33
4+ is_python3 () {
5+ " $@ " -c ' import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' > /dev/null 2>&1
6+ }
7+
48case " $OSTYPE " in
59 msys* |mingw* |cygwin* |win32* )
610 echo " Running ${me} on Windows"
7- if command -v python3 > /dev/null 2>&1 ; then
8- PYTHON_EXECUTABLE=(python3)
9- elif command -v python > /dev/null 2>&1 ; then
10- PYTHON_EXECUTABLE=(python)
11+ if command -v py > /dev/null 2>&1 && is_python3 py -3; then
12+ PYTHON_EXECUTABLE=(py -3)
1113 else
12- echo " Error: Python not found or not runnable"
13- exit 1
14+ python3_path=$( command -v python3 2> /dev/null || true)
15+ if [ -n " $python3_path " ] && [[ " $python3_path " != * WindowsApps* ]] && is_python3 python3; then
16+ PYTHON_EXECUTABLE=(python3)
17+ elif command -v python > /dev/null 2>&1 && is_python3 python; then
18+ PYTHON_EXECUTABLE=(python)
19+ else
20+ echo " Error: Python 3 not found. Please install Python 3 or disable the Microsoft Store python alias."
21+ exit 1
22+ fi
1423 fi
1524 ;;
1625 * )
1726 echo " Running ${me} on linux / mac / unix"
18- if command -v python3 > /dev/null 2>&1 ; then
27+ if command -v python3 > /dev/null 2>&1 && is_python3 python3 ; then
1928 PYTHON_EXECUTABLE=(python3)
20- elif command -v python > /dev/null 2>&1 ; then
29+ elif command -v python > /dev/null 2>&1 && is_python3 python ; then
2130 PYTHON_EXECUTABLE=(python)
2231 else
2332 echo " Error: Python not found or not runnable"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22me=$( basename " $0 " )
33
4+ is_python3 () {
5+ " $@ " -c ' import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' > /dev/null 2>&1
6+ }
7+
48case " $OSTYPE " in
59 msys* |mingw* |cygwin* |win32* )
610 echo " Running ${me} on Windows"
7- if command -v python3 > /dev/null 2>&1 ; then
8- PYTHON_EXECUTABLE=(python3)
9- elif command -v python > /dev/null 2>&1 ; then
10- PYTHON_EXECUTABLE=(python)
11+ if command -v py > /dev/null 2>&1 && is_python3 py -3; then
12+ PYTHON_EXECUTABLE=(py -3)
1113 else
12- echo " Error: Python not found or not runnable"
13- exit 1
14+ python3_path=$( command -v python3 2> /dev/null || true)
15+ if [ -n " $python3_path " ] && [[ " $python3_path " != * WindowsApps* ]] && is_python3 python3; then
16+ PYTHON_EXECUTABLE=(python3)
17+ elif command -v python > /dev/null 2>&1 && is_python3 python; then
18+ PYTHON_EXECUTABLE=(python)
19+ else
20+ echo " Error: Python 3 not found. Please install Python 3 or disable the Microsoft Store python alias."
21+ exit 1
22+ fi
1423 fi
1524 ;;
1625 * )
1726 echo " Running ${me} on linux / mac / unix"
18- if command -v python3 > /dev/null 2>&1 ; then
27+ if command -v python3 > /dev/null 2>&1 && is_python3 python3 ; then
1928 PYTHON_EXECUTABLE=(python3)
20- elif command -v python > /dev/null 2>&1 ; then
29+ elif command -v python > /dev/null 2>&1 && is_python3 python ; then
2130 PYTHON_EXECUTABLE=(python)
2231 else
2332 echo " Error: Python not found or not runnable"
You can’t perform that action at this time.
0 commit comments