Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip unavailable Python interpreters from pyenv #609

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Add path option for Python source in [#584](https://github.com/PyO3/maturin/pull/584)
* `[tool.maturin]` options from `pyproject.toml` will be used automatically in [#605](https://github.com/PyO3/maturin/pull/605)
* Skip unavailable Python interpreters from pyenv in [#609](https://github.com/PyO3/maturin/pull/609)

## [0.11.2] - 2021-07-20

Expand Down
18 changes: 15 additions & 3 deletions src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::collections::HashSet;
use std::fmt;
use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::process::Command;
use std::str;

/// This snippets will give us information about the python interpreter's
Expand Down Expand Up @@ -414,7 +414,6 @@ impl PythonInterpreter {
) -> Result<Option<PythonInterpreter>> {
let output = Command::new(&executable.as_ref())
.args(&["-c", GET_INTERPRETER_METADATA])
.stderr(Stdio::inherit())
.output();

let err_msg = format!(
Expand All @@ -426,7 +425,20 @@ impl PythonInterpreter {
if output.status.success() {
output
} else {
bail!(err_msg);
let stderr = str::from_utf8(&output.stderr).unwrap();
if stderr.starts_with(&format!(
"pyenv: {}: command not found",
executable.as_ref().display()
)) {
eprintln!(
"⚠️ Warning: skipped unavailable python interpreter '{}' from pyenv",
executable.as_ref().display()
);
return Ok(None);
} else {
eprintln!("{}", stderr);
bail!(err_msg);
}
}
}
Err(err) => {
Expand Down