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

uv build: add --keep-on-error #12292

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,10 @@ pub struct BuildArgs {
#[arg(long, overrides_with("build_logs"))]
pub no_build_logs: bool,

/// Don't delete the sdist directory upon a build error.
#[arg(long)]
pub keep_on_error: bool,

/// Always build through PEP 517, don't use the fast path for the uv build backend.
///
/// By default, uv won't create a PEP 517 build environment for packages using the uv build
Expand Down
32 changes: 28 additions & 4 deletions crates/uv/src/commands/build_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub(crate) async fn build_frontend(
settings: &ResolverSettings,
network_settings: &NetworkSettings,
no_config: bool,
keep_on_error: bool,
python_preference: PythonPreference,
python_downloads: PythonDownloads,
concurrency: Concurrency,
Expand All @@ -135,6 +136,7 @@ pub(crate) async fn build_frontend(
settings,
network_settings,
no_config,
keep_on_error,
python_preference,
python_downloads,
concurrency,
Expand Down Expand Up @@ -178,6 +180,7 @@ async fn build_impl(
settings: &ResolverSettings,
network_settings: &NetworkSettings,
no_config: bool,
keep_on_error: bool,
python_preference: PythonPreference,
python_downloads: PythonDownloads,
concurrency: Concurrency,
Expand Down Expand Up @@ -327,6 +330,7 @@ async fn build_impl(
python_request,
install_mirrors.clone(),
no_config,
keep_on_error,
workspace.as_ref(),
python_preference,
python_downloads,
Expand Down Expand Up @@ -405,6 +409,7 @@ async fn build_package(
python_request: Option<&str>,
install_mirrors: PythonInstallMirrors,
no_config: bool,
keep_on_error: bool,
workspace: Result<&Workspace, &WorkspaceError>,
python_preference: PythonPreference,
python_downloads: PythonDownloads,
Expand Down Expand Up @@ -697,8 +702,18 @@ async fn build_package(
build_output,
Some(sdist_build.normalized_filename().version()),
)
.await?;
build_results.push(wheel_build);
.await;

if keep_on_error && wheel_build.is_err() {
let path = temp_dir.into_path();
writeln!(
printer.stderr(),
"`--keep-on-error` was provided, build can be found in {}",
path.display()
)?;
}

build_results.push(wheel_build?);
}
BuildPlan::Sdist => {
let sdist_build = build_sdist(
Expand Down Expand Up @@ -812,8 +827,17 @@ async fn build_package(
build_output,
version.as_ref(),
)
.await?;
build_results.push(wheel_build);
.await;

if keep_on_error && wheel_build.is_err() {
let path = temp_dir.into_path();
writeln!(
printer.stderr(),
"`--keep-on-error` was provided, build can be found in {}",
path.display()
)?;
}
build_results.push(wheel_build?);
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
&args.settings,
&globals.network_settings,
cli.top_level.no_config,
args.keep_on_error,
globals.python_preference,
globals.python_downloads,
globals.concurrency,
Expand Down
3 changes: 3 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,7 @@ pub(crate) struct BuildSettings {
pub(crate) list: bool,
pub(crate) build_logs: bool,
pub(crate) force_pep517: bool,
pub(crate) keep_on_error: bool,
pub(crate) build_constraints: Vec<PathBuf>,
pub(crate) hash_checking: Option<HashCheckingMode>,
pub(crate) python: Option<String>,
Expand Down Expand Up @@ -2289,6 +2290,7 @@ impl BuildSettings {
no_verify_hashes,
build_logs,
no_build_logs,
keep_on_error,
python,
build,
refresh,
Expand All @@ -2314,6 +2316,7 @@ impl BuildSettings {
.filter_map(Maybe::into_option)
.collect(),
force_pep517,
keep_on_error,
hash_checking: HashCheckingMode::from_args(
flag(require_hashes, no_require_hashes),
flag(verify_hashes, no_verify_hashes),
Expand Down
Loading