Indicate which package failed in the error message for uv build --all (#7736)
## Summary Small follow up to https://github.com/astral-sh/uv/pull/7724 ## Test Plan `cargo test` --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
@@ -58,7 +58,7 @@ pub(crate) async fn build(
|
||||
cache: &Cache,
|
||||
printer: Printer,
|
||||
) -> Result<ExitStatus> {
|
||||
let results = build_impl(
|
||||
let build_result = build_impl(
|
||||
project_dir,
|
||||
src.as_deref(),
|
||||
package.as_ref(),
|
||||
@@ -82,53 +82,19 @@ pub(crate) async fn build(
|
||||
)
|
||||
.await?;
|
||||
|
||||
for result in &results {
|
||||
match result {
|
||||
Ok(assets) => match assets {
|
||||
BuiltDistributions::Wheel(wheel) => {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Successfully built {}",
|
||||
wheel.user_display().bold().cyan()
|
||||
)?;
|
||||
}
|
||||
BuiltDistributions::Sdist(sdist) => {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Successfully built {}",
|
||||
sdist.user_display().bold().cyan()
|
||||
)?;
|
||||
}
|
||||
BuiltDistributions::Both(sdist, wheel) => {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Successfully built {} and {}",
|
||||
sdist.user_display().bold().cyan(),
|
||||
wheel.user_display().bold().cyan()
|
||||
)?;
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
let mut causes = err.chain();
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"{}: {}",
|
||||
"error".red().bold(),
|
||||
causes.next().unwrap()
|
||||
)?;
|
||||
|
||||
for err in causes {
|
||||
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
match build_result {
|
||||
BuildResult::Failure => Ok(ExitStatus::Error),
|
||||
BuildResult::Success => Ok(ExitStatus::Success),
|
||||
}
|
||||
}
|
||||
|
||||
if results.iter().any(std::result::Result::is_err) {
|
||||
Ok(ExitStatus::Error)
|
||||
} else {
|
||||
Ok(ExitStatus::Success)
|
||||
}
|
||||
/// Represents the overall result of a build process.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum BuildResult {
|
||||
/// Indicates that at least one of the builds failed.
|
||||
Failure,
|
||||
/// Indicates that all builds succeeded.
|
||||
Success,
|
||||
}
|
||||
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
@@ -153,7 +119,7 @@ async fn build_impl(
|
||||
native_tls: bool,
|
||||
cache: &Cache,
|
||||
printer: Printer,
|
||||
) -> Result<Vec<Result<BuiltDistributions>>> {
|
||||
) -> Result<BuildResult> {
|
||||
// Extract the resolver settings.
|
||||
let ResolverSettingsRef {
|
||||
index_locations,
|
||||
@@ -261,9 +227,9 @@ async fn build_impl(
|
||||
vec![AnnotatedSource::from(src)]
|
||||
};
|
||||
|
||||
let builds = packages.into_iter().map(|src| {
|
||||
build_package(
|
||||
src,
|
||||
let results: Vec<_> = futures::future::join_all(packages.into_iter().map(|source| {
|
||||
let future = build_package(
|
||||
source.clone(),
|
||||
output_dir,
|
||||
python_request,
|
||||
no_config,
|
||||
@@ -293,10 +259,58 @@ async fn build_impl(
|
||||
dependency_metadata,
|
||||
link_mode,
|
||||
config_setting,
|
||||
)
|
||||
});
|
||||
);
|
||||
async {
|
||||
let result = future.await;
|
||||
(source, result)
|
||||
}
|
||||
}))
|
||||
.await;
|
||||
|
||||
Ok(futures::future::join_all(builds).await)
|
||||
for (source, result) in &results {
|
||||
match result {
|
||||
Ok(assets) => match assets {
|
||||
BuiltDistributions::Wheel(wheel) => {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Successfully built {}",
|
||||
wheel.user_display().bold().cyan()
|
||||
)?;
|
||||
}
|
||||
BuiltDistributions::Sdist(sdist) => {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Successfully built {}",
|
||||
sdist.user_display().bold().cyan()
|
||||
)?;
|
||||
}
|
||||
BuiltDistributions::Both(sdist, wheel) => {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Successfully built {} and {}",
|
||||
sdist.user_display().bold().cyan(),
|
||||
wheel.user_display().bold().cyan()
|
||||
)?;
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
let mut causes = err.chain();
|
||||
|
||||
let message = format!("{}: {}", "error".red().bold(), causes.next().unwrap());
|
||||
writeln!(printer.stderr(), "{}", source.annotate(&message))?;
|
||||
|
||||
for err in causes {
|
||||
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if results.iter().any(|(_, result)| result.is_err()) {
|
||||
Ok(BuildResult::Failure)
|
||||
} else {
|
||||
Ok(BuildResult::Success)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
|
||||
@@ -1328,7 +1328,7 @@ fn build_all_with_failure() -> Result<()> {
|
||||
[PKG] Building wheel from source distribution...
|
||||
[PKG] Building wheel from source distribution...
|
||||
Successfully built packages/member_a/dist/member_a-0.1.0.tar.gz and packages/member_a/dist/member_a-0.1.0-py3-none-any.whl
|
||||
error: Build backend failed to determine extra requires with `build_sdist()` with exit status: 1
|
||||
[PKG] error: Build backend failed to determine extra requires with `build_sdist()` with exit status: 1
|
||||
Successfully built dist/project-0.1.0.tar.gz and dist/project-0.1.0-py3-none-any.whl
|
||||
"###);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user