about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-03-30 09:10:04 +0200
committerGitHub <noreply@github.com>2022-03-30 09:10:04 +0200
commit33730c857fd4706eb9dedba6af1f243d16626e1d (patch)
tree546d8b9c5b7024955a88ce28469ef52a2bcceaca
parente332f3b45eb1df4ee322e0ce4d53b90d6eaa520a (diff)
parentf5fb293295241e64d745ed63da5c603eed0ebc22 (diff)
downloadrust-33730c857fd4706eb9dedba6af1f243d16626e1d.tar.gz
rust-33730c857fd4706eb9dedba6af1f243d16626e1d.zip
Rollup merge of #95443 - jyn514:clarify-python-search-logic, r=Dylan-DPC
Clarify how `src/tools/x` searches for python

Before, it confusingly looked like `python` was chosen last instead of first.
-rw-r--r--src/tools/x/src/main.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tools/x/src/main.rs b/src/tools/x/src/main.rs
index 8c47559b369..57d548f313d 100644
--- a/src/tools/x/src/main.rs
+++ b/src/tools/x/src/main.rs
@@ -26,6 +26,7 @@ fn python() -> &'static str {
     let mut python3 = false;
 
     for dir in env::split_paths(&val) {
+        // `python` should always take precedence over python2 / python3 if it exists
         if dir.join(PYTHON).exists() {
             return PYTHON;
         }
@@ -34,11 +35,14 @@ fn python() -> &'static str {
         python3 |= dir.join(PYTHON3).exists();
     }
 
+    // try 3 before 2
     if python3 {
         PYTHON3
     } else if python2 {
         PYTHON2
     } else {
+        // We would have returned early if we found that python is installed ...
+        // maybe this should panic with an error instead?
         PYTHON
     }
 }