Skip to content

Commit dd4b27b

Browse files
Allow --no-build to validate lock (#9024)
## Summary Just as we don't enforce tag compliance, we shouldn't enforce `--no-build` when validating the lockfile. If we end up building from source, the distribution database will correctly error. Closes #9016.
1 parent a3c2a36 commit dd4b27b

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

crates/uv-resolver/src/lock/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ impl Lock {
974974
overrides: &[Requirement],
975975
dependency_metadata: &DependencyMetadata,
976976
indexes: Option<&IndexLocations>,
977-
build_options: &BuildOptions,
978977
tags: &Tags,
979978
hasher: &HashStrategy,
980979
index: &InMemoryIndex,
@@ -1183,8 +1182,13 @@ impl Lock {
11831182
// Get the metadata for the distribution.
11841183
let dist = package.to_dist(
11851184
workspace.install_path(),
1185+
// When validating, it's okay to use wheels that don't match the current platform.
11861186
TagPolicy::Preferred(tags),
1187-
build_options,
1187+
// When validating, it's okay to use (e.g.) a source distribution with `--no-build`.
1188+
// We're just trying to determine whether the lockfile is up-to-date. If we end
1189+
// up needing to build a source distribution in order to do so, below, we'll error
1190+
// there.
1191+
&BuildOptions::default(),
11881192
)?;
11891193

11901194
// Fetch the metadata for the distribution.

crates/uv/src/commands/project/lock.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use tracing::debug;
1111
use uv_cache::Cache;
1212
use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder};
1313
use uv_configuration::{
14-
BuildOptions, Concurrency, Constraints, ExtrasSpecification, LowerBound, Reinstall,
15-
TrustedHost, Upgrade,
14+
Concurrency, Constraints, ExtrasSpecification, LowerBound, Reinstall, TrustedHost, Upgrade,
1615
};
1716
use uv_dispatch::BuildDispatch;
1817
use uv_distribution::DistributionDatabase;
@@ -531,7 +530,6 @@ async fn do_lock(
531530
interpreter,
532531
&requires_python,
533532
index_locations,
534-
build_options,
535533
upgrade,
536534
&options,
537535
&hasher,
@@ -714,7 +712,6 @@ impl ValidatedLock {
714712
interpreter: &Interpreter,
715713
requires_python: &RequiresPython,
716714
index_locations: &IndexLocations,
717-
build_options: &BuildOptions,
718715
upgrade: &Upgrade,
719716
options: &Options,
720717
hasher: &HashStrategy,
@@ -841,7 +838,6 @@ impl ValidatedLock {
841838
overrides,
842839
dependency_metadata,
843840
indexes,
844-
build_options,
845841
interpreter.tags()?,
846842
hasher,
847843
index,

crates/uv/tests/it/sync.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,20 +1997,18 @@ fn no_install_project_no_build() -> Result<()> {
19971997
----- stdout -----
19981998
19991999
----- stderr -----
2000-
warning: Failed to validate existing lockfile: Distribution `project==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution
20012000
Resolved 4 packages in [TIME]
20022001
error: Distribution `project==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution
20032002
"###);
20042003

20052004
// But it's fine to combine `--no-install-project` with `--no-build`. We shouldn't error, since
20062005
// we aren't building the project.
2007-
uv_snapshot!(context.filters(), context.sync().arg("--no-install-project").arg("--no-build"), @r###"
2006+
uv_snapshot!(context.filters(), context.sync().arg("--no-install-project").arg("--no-build").arg("--locked"), @r###"
20082007
success: true
20092008
exit_code: 0
20102009
----- stdout -----
20112010
20122011
----- stderr -----
2013-
warning: Failed to validate existing lockfile: Distribution `project==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution
20142012
Resolved 4 packages in [TIME]
20152013
Prepared 3 packages in [TIME]
20162014
Installed 3 packages in [TIME]

0 commit comments

Comments
 (0)