Skip to content

Commit aa29a8b

Browse files
authored
Rollup merge of #104350 - SparkyPotato:fix-x-wrapper, r=jyn514
Fix x finding Python on Windows `x` searches through the path for `{dir}/python{2|3}?`, but this fails on Windows because the appropriate path is `{dir}/python.exe`. This PR adds the expected `.exe` extension on Windows while searching.
2 parents 5763fa7 + 56dfb70 commit aa29a8b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/tools/x/src/main.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//! `x.py`, in that order of preference.
99
1010
use std::{
11-
env, io,
11+
env::{self, consts::EXE_EXTENSION},
12+
io,
1213
process::{self, Command, ExitStatus},
1314
};
1415

@@ -27,12 +28,12 @@ fn python() -> &'static str {
2728

2829
for dir in env::split_paths(&val) {
2930
// `python` should always take precedence over python2 / python3 if it exists
30-
if dir.join(PYTHON).exists() {
31+
if dir.join(PYTHON).with_extension(EXE_EXTENSION).exists() {
3132
return PYTHON;
3233
}
3334

34-
python2 |= dir.join(PYTHON2).exists();
35-
python3 |= dir.join(PYTHON3).exists();
35+
python2 |= dir.join(PYTHON2).with_extension(EXE_EXTENSION).exists();
36+
python3 |= dir.join(PYTHON3).with_extension(EXE_EXTENSION).exists();
3637
}
3738

3839
// try 3 before 2

0 commit comments

Comments
 (0)