Skip to content

Commit

Permalink
Merge pull request #944 from messense/windows-store
Browse files Browse the repository at this point in the history
Auto-detect Python Installs from Microsoft Store
  • Loading branch information
messense authored May 27, 2022
2 parents aefdf8f + 17df675 commit dccf2f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add network proxy support to upload command in [#939](https://github.com/PyO3/maturin/pull/939)
* Fix python interpreter detection on arm64 Windows in [#940](https://github.com/PyO3/maturin/pull/940)
* Fallback to `py -X.Y` when `pythonX.Y` cannot be found on Windows in [#943](https://github.com/PyO3/maturin/pull/943)
* Auto-detect Python Installs from Microsoft Store in [#944](https://github.com/PyO3/maturin/pull/944)

## [0.12.17] - 2022-05-18

Expand Down
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 dccf2f3

Please sign in to comment.