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
2 changes: 2 additions & 0 deletions crates/uv-distribution-types/src/build_requires.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ impl ExtraBuildRequires {
/// Apply runtime constraints from a resolution to the extra build requirements.
pub fn match_runtime(self, resolution: &Resolution) -> Result<Self, ExtraBuildRequiresError> {
self.into_iter()
.filter(|(_, requirements)| !requirements.is_empty())
.filter(|(name, _)| resolution.distributions().any(|dist| dist.name() == name))
.map(|(name, requirements)| {
let requirements = requirements
.into_iter()
Expand Down
38 changes: 38 additions & 0 deletions crates/uv/tests/it/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13360,6 +13360,44 @@ fn reject_unmatched_runtime() -> Result<()> {
Ok(())
}

#[test]
fn match_runtime_optional() -> Result<()> {
let context = TestContext::new("3.12").with_exclude_newer("2025-01-01T00:00Z");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "foo"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[project.optional-dependencies]
bar = ["iniconfig", "typing-extensions"]

[tool.uv.sources]
typing-extensions = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz" }

[tool.uv.extra-build-dependencies]
typing-extensions = [{ requirement = "iniconfig", match-runtime = true }]
"#,
)?;

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 3 packages in [TIME]
Audited in [TIME]
");

Ok(())
}

#[test]
fn sync_extra_build_dependencies_cache() -> Result<()> {
let context = TestContext::new("3.12");
Expand Down
Loading