Skip to content

Commit db01fc9

Browse files
SYS-8273 confirm a real interpreter is being used instead of microsoft store alias
1 parent 6100ba4 commit db01fc9

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

main/commit-msg

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/usr/bin/env bash
22
me=$(basename "$0")
33

4+
is_python3() {
5+
"$1" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
6+
}
7+
48
case "$OSTYPE" in
59
msys*|mingw*|cygwin*|win32*)
610
echo "Running ${me} on Windows"
7-
if command -v python3 > /dev/null 2>&1; then
11+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
812
PYTHON_EXECUTABLE=(python3)
9-
elif command -v python > /dev/null 2>&1; then
13+
elif command -v py >/dev/null 2>&1 && py -3 -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1; then
14+
PYTHON_EXECUTABLE=(py -3)
15+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
1016
PYTHON_EXECUTABLE=(python)
1117
else
1218
echo "Error: Python not found or not runnable"
@@ -15,9 +21,9 @@ case "$OSTYPE" in
1521
;;
1622
*)
1723
echo "Running ${me} on linux / mac / unix"
18-
if command -v python3 > /dev/null 2>&1; then
24+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
1925
PYTHON_EXECUTABLE=(python3)
20-
elif command -v python > /dev/null 2>&1; then
26+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
2127
PYTHON_EXECUTABLE=(python)
2228
else
2329
echo "Error: Python not found or not runnable"

main/pre-commit

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/usr/bin/env bash
22
me=$(basename "$0")
33

4+
is_python3() {
5+
"$1" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
6+
}
7+
48
case "$OSTYPE" in
59
msys*|mingw*|cygwin*|win32*)
610
echo "Running ${me} on Windows"
7-
if command -v python3 > /dev/null 2>&1; then
11+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
812
PYTHON_EXECUTABLE=(python3)
9-
elif command -v python > /dev/null 2>&1; then
13+
elif command -v py >/dev/null 2>&1 && py -3 -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1; then
14+
PYTHON_EXECUTABLE=(py -3)
15+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
1016
PYTHON_EXECUTABLE=(python)
1117
else
1218
echo "Error: Python not found or not runnable"
@@ -15,9 +21,9 @@ case "$OSTYPE" in
1521
;;
1622
*)
1723
echo "Running ${me} on linux / mac / unix"
18-
if command -v python3 > /dev/null 2>&1; then
24+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
1925
PYTHON_EXECUTABLE=(python3)
20-
elif command -v python > /dev/null 2>&1; then
26+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
2127
PYTHON_EXECUTABLE=(python)
2228
else
2329
echo "Error: Python not found or not runnable"

main/pre-merge-commit

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/usr/bin/env bash
22
me=$(basename "$0")
33

4+
is_python3() {
5+
"$1" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
6+
}
7+
48
case "$OSTYPE" in
59
msys*|mingw*|cygwin*|win32*)
610
echo "Running ${me} on Windows"
7-
if command -v python3 > /dev/null 2>&1; then
11+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
812
PYTHON_EXECUTABLE=(python3)
9-
elif command -v python > /dev/null 2>&1; then
13+
elif command -v py >/dev/null 2>&1 && py -3 -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1; then
14+
PYTHON_EXECUTABLE=(py -3)
15+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
1016
PYTHON_EXECUTABLE=(python)
1117
else
1218
echo "Error: Python not found or not runnable"
@@ -15,9 +21,9 @@ case "$OSTYPE" in
1521
;;
1622
*)
1723
echo "Running ${me} on linux / mac / unix"
18-
if command -v python3 > /dev/null 2>&1; then
24+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
1925
PYTHON_EXECUTABLE=(python3)
20-
elif command -v python > /dev/null 2>&1; then
26+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
2127
PYTHON_EXECUTABLE=(python)
2228
else
2329
echo "Error: Python not found or not runnable"

0 commit comments

Comments
 (0)