Skip to content

Commit

Permalink
Rollup merge of #95443 - jyn514:clarify-python-search-logic, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Clarify how `src/tools/x` searches for python

Before, it confusingly looked like `python` was chosen last instead of first.
  • Loading branch information
Dylan-DPC committed Mar 30, 2022
2 parents e332f3b + f5fb293 commit 33730c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tools/x/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
}
}
Expand Down

0 comments on commit 33730c8

Please sign in to comment.