about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2025-02-13 10:14:06 -0500
committerjyn <github@jyn.dev>2025-02-13 10:24:54 -0500
commit1cac5fa5f9f371db4789ea928e1d2769d4cd921b (patch)
treefc91722163cc6531e344b48f22a65e17a7eada30
parent4a43094662727040d8522163f295b19d1aed0e49 (diff)
downloadrust-1cac5fa5f9f371db4789ea928e1d2769d4cd921b.tar.gz
rust-1cac5fa5f9f371db4789ea928e1d2769d4cd921b.zip
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).
-rwxr-xr-xx8
1 files changed, 7 insertions, 1 deletions
diff --git a/x b/x
index e656d37c1e4..551cfe6efbf 100755
--- a/x
+++ b/x
@@ -25,7 +25,13 @@ xpy=$(dirname "$(realpath "$0")")/x.py
 
 # On Windows, `py -3` sometimes works. We need to try it first because `python3`
 # sometimes tries to launch the app store on Windows.
-for SEARCH_PYTHON in py python3 python python2; do
+# On MacOS, `py` tries to install "Developer command line tools". Try `python3` first.
+# NOTE: running `bash -c ./x` from Windows doesn't set OSTYPE.
+case ${OSTYPE:-} in
+    cygwin*|msys*) SEARCH="py python3 python python2";;
+    *) SEARCH="python3 python py python2";;
+esac
+for SEARCH_PYTHON in $SEARCH; do
     if python=$(command -v $SEARCH_PYTHON) && [ -x "$python" ]; then
         if [ $SEARCH_PYTHON = py ]; then
             extra_arg="-3"