Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f22b939

Browse files
authoredMar 5, 2025
Rollup merge of #136975 - jyn514:macos-x, r=Mark-Simulacrum
Look for `python3` first on MacOS, not `py` `py` is not installed by default *and* trying to run it results in a popup asking if you want to install it. `python3` is installed by default. This hopefully should not be too disruptive to people on Windows, since they should be going through `x.ps1` instead anyway. Just in case, I've added a check for Cygwin and Msys (i'm not sure how else you'd get a bash shell on windows). I've tested this on macOS, WSL, "git bash" (which appears to be MSYS), and MSVC with `bash -c ./x` (which runs in WSL, but differently than interactive bash 🙃). I haven't tested Cygwin, which is unsupported anyway, but the code tries to make it work.
2 parents 9aaf46e + 1cac5fa commit f22b939

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎x

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ xpy=$(dirname "$(realpath "$0")")/x.py
2525

2626
# On Windows, `py -3` sometimes works. We need to try it first because `python3`
2727
# sometimes tries to launch the app store on Windows.
28-
for SEARCH_PYTHON in py python3 python python2; do
28+
# On MacOS, `py` tries to install "Developer command line tools". Try `python3` first.
29+
# NOTE: running `bash -c ./x` from Windows doesn't set OSTYPE.
30+
case ${OSTYPE:-} in
31+
cygwin*|msys*) SEARCH="py python3 python python2";;
32+
*) SEARCH="python3 python py python2";;
33+
esac
34+
for SEARCH_PYTHON in $SEARCH; do
2935
if python=$(command -v $SEARCH_PYTHON) && [ -x "$python" ]; then
3036
if [ $SEARCH_PYTHON = py ]; then
3137
extra_arg="-3"

0 commit comments

Comments
 (0)
Failed to load comments.