Skip to content

Commit

Permalink
Auto-detect Python Installs from Microsoft Store
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed May 27, 2022
1 parent aefdf8f commit ecf37f7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ fn find_all_windows(target: &Target, min_python_minor: usize) -> Result<Vec<Stri
}
}
}

// Fallback to pythonX.Y for Microsoft Store versions
for minor in min_python_minor..MAXIMUM_PYTHON_MINOR {
if !versions_found.contains(&(3, minor)) {
interpreter.push(format!("python3.{}", minor));
versions_found.insert((3, minor));
}
}

if interpreter.is_empty() {
bail!(
"Could not find any interpreters, are you sure you have python installed on your PATH?"
Expand Down Expand Up @@ -501,8 +510,11 @@ impl PythonInterpreter {
let output = Command::new("py")
.arg(format!("-{}", ver))
.args(&["-c", GET_INTERPRETER_METADATA])
.output()?;
output
.output();
match output {
Ok(output) if output.status.success() => output,
_ => return Ok(None),
}
} else {
return Ok(None);
}
Expand Down

0 comments on commit ecf37f7

Please sign in to comment.