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

Simpler and more resilient pip compile tests #426

Merged
merged 2 commits into from
Nov 15, 2023
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
12 changes: 10 additions & 2 deletions crates/puffin-cli/src/commands/venv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt::Write;
use std::path::Path;
use std::path::{Path, PathBuf};

use anyhow::Result;
use colored::Colorize;
Expand Down Expand Up @@ -37,6 +37,10 @@ enum VenvError {
#[diagnostic(code(puffin::venv::python_not_found))]
PythonNotFound,

#[error("Unable to find a Python interpreter {0}")]
#[diagnostic(code(puffin::venv::python_not_found))]
UserPythonNotFound(PathBuf),

#[error("Failed to extract Python interpreter info")]
#[diagnostic(code(puffin::venv::interpreter))]
InterpreterError(#[source] anyhow::Error),
Expand All @@ -54,7 +58,11 @@ fn venv_impl(
) -> miette::Result<ExitStatus> {
// Locate the Python interpreter.
let base_python = if let Some(base_python) = base_python {
fs::canonicalize(base_python).into_diagnostic()?
fs::canonicalize(
which::which_global(base_python)
.map_err(|_| VenvError::UserPythonNotFound(base_python.to_path_buf()))?,
)
.into_diagnostic()?
} else {
fs::canonicalize(
which::which_global("python3")
Expand Down
Loading