Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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: 7 additions & 5 deletions crates/pixi_core/src/lock_file/resolve/build_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ pub struct LazyBuildDispatchDependencies {
last_error: OnceCell<LazyBuildDispatchError>,
}

impl LazyBuildDispatchDependencies {
/// Get the last initialization error if available
pub fn last_initialization_error(&self) -> Option<&LazyBuildDispatchError> {
self.last_error.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it would be doable to pull this out, or we need to rename the struct ;)

}
}

#[derive(Debug, thiserror::Error, miette::Diagnostic)]
pub enum LazyBuildDispatchError {
#[error(
Expand Down Expand Up @@ -276,11 +283,6 @@ impl IsBuildBackendError for LazyBuildDispatchError {
}

impl<'a> LazyBuildDispatch<'a> {
/// Get the last initialization error if available
pub fn last_initialization_error(&self) -> Option<&LazyBuildDispatchError> {
self.lazy_deps.last_error.get()
}

/// Create a new `PixiBuildDispatch` instance.
#[allow(clippy::too_many_arguments)]
pub fn new(
Expand Down
66 changes: 37 additions & 29 deletions crates/pixi_core/src/lock_file/resolve/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ pub enum SolveError {
#[error(transparent)]
#[diagnostic(transparent)]
LookAhead(Box<dyn miette::Diagnostic + Send + Sync + 'static>),

#[error(transparent)]
#[diagnostic(transparent)]
Locking(Box<dyn miette::Diagnostic + Send + Sync + 'static>),
}

/// Creates a custom `SolveError` from a `ResolveError`.
Expand Down Expand Up @@ -747,18 +751,46 @@ pub async fn resolve_pypi(
UvReporterOptions::new().with_existing(pb.clone()),
));

resolver
let resolution = resolver
.resolve()
.await
.map_err(|e| create_solve_error(e, &conda_python_packages))
.map_err(|e| create_solve_error(e, &conda_python_packages))?;

let resolution = Resolution::from(resolution);

// Print the overridden package requests
print_overridden_requests(package_requests.borrow().deref());

// Print any diagnostics
for diagnostic in resolution.diagnostics() {
tracing::warn!("{}", diagnostic.message());
}

let locked_packages = lock_pypi_packages(
conda_python_packages,
&lazy_build_dispatch,
&registry_client,
resolution,
&context.capabilities,
context.concurrency.downloads,
project_root,
&original_git_references,
)
.await
.map_err(|e| SolveError::Locking(e.into()))?;

let conda_task = lazy_build_dispatch.conda_task;

Ok::<_, SolveError>((locked_packages, conda_task))
});

// We try to distinguish between build dispatch panics and any other panics that occur
let resolution = match resolution_future.catch_unwind().await {
let (locked_packages, conda_task) = match resolution_future.catch_unwind().await {
Ok(result) => result?,
Err(panic_payload) => {
// Try to get the stored initialization error from the lazy build dispatch
if let Some(stored_error) = lazy_build_dispatch.last_initialization_error() {
// Try to get the stored initialization error from the lazy build dispatch dependencies
if let Some(stored_error) = lazy_build_dispatch_dependencies.last_initialization_error()
{
return Err(SolveError::BuildDispatchPanic {
message: format!("{stored_error}"),
}
Expand All @@ -780,30 +812,6 @@ pub async fn resolve_pypi(
}
}
};
let resolution = Resolution::from(resolution);

// Print the overridden package requests
print_overridden_requests(package_requests.borrow().deref());

// Print any diagnostics
for diagnostic in resolution.diagnostics() {
tracing::warn!("{}", diagnostic.message());
}

// Collect resolution into locked packages
let locked_packages = lock_pypi_packages(
conda_python_packages,
&lazy_build_dispatch,
&registry_client,
resolution,
&context.capabilities,
context.concurrency.downloads,
project_root,
&original_git_references,
)
.await?;

let conda_task = lazy_build_dispatch.conda_task;

Ok((locked_packages, conda_task))
}
Expand Down
Loading