Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl BuildContext for BuildDispatch<'_> {
self.index_locations,
self.config_settings,
self.config_settings_package,
self.extra_build_dependencies(),
self.cache(),
venv,
tags,
Expand Down Expand Up @@ -460,7 +461,7 @@ impl BuildContext for BuildDispatch<'_> {
self.workspace_cache(),
config_settings,
self.build_isolation,
&self.extra_build_requires.extra_build_dependencies,
self.extra_build_dependencies(),
&build_stack,
build_kind,
self.build_extra_env_vars.clone(),
Expand Down
36 changes: 28 additions & 8 deletions crates/uv-distribution/src/index/built_wheel_index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::borrow::Cow;

use uv_cache::{Cache, CacheBucket, CacheShard, WheelCache};
use uv_cache_info::CacheInfo;
use uv_cache_key::cache_digest;
Expand All @@ -9,6 +10,7 @@ use uv_distribution_types::{
use uv_normalize::PackageName;
use uv_platform_tags::Tags;
use uv_types::HashStrategy;
use uv_workspace::pyproject::ExtraBuildDependencies;

use crate::Error;
use crate::index::cached_wheel::CachedWheel;
Expand All @@ -22,6 +24,7 @@ pub struct BuiltWheelIndex<'a> {
hasher: &'a HashStrategy,
config_settings: &'a ConfigSettings,
config_settings_package: &'a PackageConfigSettings,
extra_build_dependencies: &'a ExtraBuildDependencies,
}

impl<'a> BuiltWheelIndex<'a> {
Expand All @@ -32,13 +35,15 @@ impl<'a> BuiltWheelIndex<'a> {
hasher: &'a HashStrategy,
config_settings: &'a ConfigSettings,
config_settings_package: &'a PackageConfigSettings,
extra_build_dependencies: &'a ExtraBuildDependencies,
) -> Self {
Self {
cache,
tags,
hasher,
config_settings,
config_settings_package,
extra_build_dependencies,
}
}

Expand Down Expand Up @@ -69,10 +74,11 @@ impl<'a> BuiltWheelIndex<'a> {

// If there are build settings, we need to scope to a cache shard.
let config_settings = self.config_settings_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() {
let extra_build_deps = self.extra_build_dependencies_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() && extra_build_deps.is_empty() {
cache_shard
} else {
cache_shard.shard(cache_digest(&config_settings))
cache_shard.shard(cache_digest(&(&config_settings, extra_build_deps)))
};

Ok(self.find(&cache_shard))
Expand Down Expand Up @@ -107,10 +113,11 @@ impl<'a> BuiltWheelIndex<'a> {

// If there are build settings, we need to scope to a cache shard.
let config_settings = self.config_settings_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() {
let extra_build_deps = self.extra_build_dependencies_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() && extra_build_deps.is_empty() {
cache_shard
} else {
cache_shard.shard(cache_digest(&config_settings))
cache_shard.shard(cache_digest(&(&config_settings, extra_build_deps)))
};

Ok(self
Expand Down Expand Up @@ -156,10 +163,11 @@ impl<'a> BuiltWheelIndex<'a> {

// If there are build settings, we need to scope to a cache shard.
let config_settings = self.config_settings_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() {
let extra_build_deps = self.extra_build_dependencies_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() && extra_build_deps.is_empty() {
cache_shard
} else {
cache_shard.shard(cache_digest(&config_settings))
cache_shard.shard(cache_digest(&(&config_settings, extra_build_deps)))
};

Ok(self
Expand All @@ -183,10 +191,11 @@ impl<'a> BuiltWheelIndex<'a> {

// If there are build settings, we need to scope to a cache shard.
let config_settings = self.config_settings_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() {
let extra_build_deps = self.extra_build_dependencies_for(&source_dist.name);
let cache_shard = if config_settings.is_empty() && extra_build_deps.is_empty() {
cache_shard
} else {
cache_shard.shard(cache_digest(&config_settings))
cache_shard.shard(cache_digest(&(&config_settings, extra_build_deps)))
};

self.find(&cache_shard)
Expand Down Expand Up @@ -257,4 +266,15 @@ impl<'a> BuiltWheelIndex<'a> {
Cow::Borrowed(self.config_settings)
}
}

/// Determine the extra build dependencies for the given package name.
fn extra_build_dependencies_for(
&self,
name: &PackageName,
) -> &[uv_pep508::Requirement<uv_pypi_types::VerbatimParsedUrl>] {
self.extra_build_dependencies
.get(name)
.map(Vec::as_slice)
.unwrap_or(&[])
}
}
2 changes: 1 addition & 1 deletion crates/uv-distribution/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context
.extra_build_dependencies()
.get(name)
.map(|v| v.as_slice())
.map(Vec::as_slice)
})
.unwrap_or(&[])
}
Expand Down
1 change: 1 addition & 0 deletions crates/uv-installer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ uv-redacted = { workspace = true }
uv-static = { workspace = true }
uv-types = { workspace = true }
uv-warnings = { workspace = true }
uv-workspace = { workspace = true }

anyhow = { workspace = true }
async-channel = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion crates/uv-installer/src/plan.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::{Result, bail};
use std::sync::Arc;

use anyhow::{Result, bail};
use tracing::{debug, warn};

use uv_cache::{Cache, CacheBucket, WheelCache};
Expand All @@ -17,6 +18,7 @@ use uv_platform_tags::Tags;
use uv_pypi_types::VerbatimParsedUrl;
use uv_python::PythonEnvironment;
use uv_types::HashStrategy;
use uv_workspace::pyproject::ExtraBuildDependencies;

use crate::SitePackages;
use crate::satisfies::RequirementSatisfaction;
Expand Down Expand Up @@ -53,6 +55,7 @@ impl<'a> Planner<'a> {
index_locations: &IndexLocations,
config_settings: &ConfigSettings,
config_settings_package: &PackageConfigSettings,
extra_build_dependencies: &ExtraBuildDependencies,
cache: &Cache,
venv: &PythonEnvironment,
tags: &Tags,
Expand All @@ -66,6 +69,7 @@ impl<'a> Planner<'a> {
hasher,
config_settings,
config_settings_package,
extra_build_dependencies,
);

let mut cached = vec![];
Expand Down
3 changes: 2 additions & 1 deletion crates/uv-types/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use uv_git::GitResolver;
use uv_pep508::PackageName;
use uv_python::{Interpreter, PythonEnvironment};
use uv_workspace::WorkspaceCache;
use uv_workspace::pyproject::ExtraBuildDependencies;

use crate::BuildArena;

Expand Down Expand Up @@ -104,7 +105,7 @@ pub trait BuildContext {
fn workspace_cache(&self) -> &WorkspaceCache;

/// Get the extra build dependencies.
fn extra_build_dependencies(&self) -> &uv_workspace::pyproject::ExtraBuildDependencies;
fn extra_build_dependencies(&self) -> &ExtraBuildDependencies;

/// Resolve the given requirements into a ready-to-install set of package versions.
fn resolve<'a>(
Expand Down
8 changes: 5 additions & 3 deletions crates/uv/src/commands/pip/operations.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! Common operations shared across the `pip` API and subcommands.

use anyhow::{Context, anyhow};
use itertools::Itertools;
use owo_colors::OwoColorize;
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::fmt::Write;
use std::path::PathBuf;
use std::sync::Arc;

use anyhow::{Context, anyhow};
use itertools::Itertools;
use owo_colors::OwoColorize;
use tracing::debug;

use uv_cache::Cache;
Expand Down Expand Up @@ -468,6 +469,7 @@ pub(crate) async fn install(
index_urls,
config_settings,
config_settings_package,
build_dispatch.extra_build_dependencies(),
cache,
venv,
tags,
Expand Down
13 changes: 13 additions & 0 deletions crates/uv/tests/it/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,19 @@ fn sync_extra_build_dependencies() -> Result<()> {
+ child==0.1.0 (from file://[TEMP_DIR]/child)
");

context.venv().arg("--clear").assert().success();
uv_snapshot!(context.filters(), context.sync(), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
warning: The `extra-build-dependencies` option is experimental and may change without warning. Pass `--preview-features extra-build-dependencies` to disable this warning.
Resolved [N] packages in [TIME]
Installed [N] packages in [TIME]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On main, this shows Prepared [N] packages in [TIME] despite them all coming from the cache.

+ child==0.1.0 (from file://[TEMP_DIR]/child)
");

// Adding `extra-build-dependencies` with the wrong name should fail the build
// (the cache is invalidated when extra build dependencies change)
pyproject_toml.write_str(indoc! {r#"
Expand Down
Loading