Skip to content

Commit 7ec79a1

Browse files
SYS-8273 py -3 pushed to top
1 parent 5283d7a commit 7ec79a1

3 files changed

Lines changed: 39 additions & 30 deletions

File tree

main/commit-msg

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22
me=$(basename "$0")
33

44
is_python3() {
5-
"$1" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
5+
"$@" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
66
}
77

88
case "$OSTYPE" in
99
msys*|mingw*|cygwin*|win32*)
1010
echo "Running ${me} on Windows"
11-
if command -v python3 > /dev/null 2>&1 && is_python3 python3; then
12-
PYTHON_EXECUTABLE=(python3)
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
11+
if command -v py >/dev/null 2>&1 && is_python3 py -3; then
1412
PYTHON_EXECUTABLE=(py -3)
15-
elif command -v python > /dev/null 2>&1 && is_python3 python; then
16-
PYTHON_EXECUTABLE=(python)
1713
else
18-
echo "Error: Python not found or not runnable"
19-
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
2023
fi
2124
;;
2225
*)
2326
echo "Running ${me} on linux / mac / unix"
24-
if command -v python3 > /dev/null 2>&1 && is_python3 python3; then
27+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
2528
PYTHON_EXECUTABLE=(python3)
26-
elif command -v python > /dev/null 2>&1 && is_python3 python; then
29+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
2730
PYTHON_EXECUTABLE=(python)
2831
else
2932
echo "Error: Python not found or not runnable"

main/pre-commit

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22
me=$(basename "$0")
33

44
is_python3() {
5-
"$1" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
5+
"$@" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
66
}
77

88
case "$OSTYPE" in
99
msys*|mingw*|cygwin*|win32*)
1010
echo "Running ${me} on Windows"
11-
if command -v python3 > /dev/null 2>&1 && is_python3 python3; then
12-
PYTHON_EXECUTABLE=(python3)
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
11+
if command -v py >/dev/null 2>&1 && is_python3 py -3; then
1412
PYTHON_EXECUTABLE=(py -3)
15-
elif command -v python > /dev/null 2>&1 && is_python3 python; then
16-
PYTHON_EXECUTABLE=(python)
1713
else
18-
echo "Error: Python not found or not runnable"
19-
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
2023
fi
2124
;;
2225
*)
2326
echo "Running ${me} on linux / mac / unix"
24-
if command -v python3 > /dev/null 2>&1 && is_python3 python3; then
27+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
2528
PYTHON_EXECUTABLE=(python3)
26-
elif command -v python > /dev/null 2>&1 && is_python3 python; then
29+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
2730
PYTHON_EXECUTABLE=(python)
2831
else
2932
echo "Error: Python not found or not runnable"

main/pre-merge-commit

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22
me=$(basename "$0")
33

44
is_python3() {
5-
"$1" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
5+
"$@" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
66
}
77

88
case "$OSTYPE" in
99
msys*|mingw*|cygwin*|win32*)
1010
echo "Running ${me} on Windows"
11-
if command -v python3 > /dev/null 2>&1 && is_python3 python3; then
12-
PYTHON_EXECUTABLE=(python3)
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
11+
if command -v py >/dev/null 2>&1 && is_python3 py -3; then
1412
PYTHON_EXECUTABLE=(py -3)
15-
elif command -v python > /dev/null 2>&1 && is_python3 python; then
16-
PYTHON_EXECUTABLE=(python)
1713
else
18-
echo "Error: Python not found or not runnable"
19-
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
2023
fi
2124
;;
2225
*)
2326
echo "Running ${me} on linux / mac / unix"
24-
if command -v python3 > /dev/null 2>&1 && is_python3 python3; then
27+
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
2528
PYTHON_EXECUTABLE=(python3)
26-
elif command -v python > /dev/null 2>&1 && is_python3 python; then
29+
elif command -v python >/dev/null 2>&1 && is_python3 python; then
2730
PYTHON_EXECUTABLE=(python)
2831
else
2932
echo "Error: Python not found or not runnable"

0 commit comments

Comments
 (0)