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
13 changes: 12 additions & 1 deletion crates/uv/src/commands/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2827,11 +2827,22 @@ pub(crate) fn script_specification(
.map_ok(LoweredRequirement::into_inner)
})
.collect::<Result<Vec<_>, _>>()?;
let excludes = script
.metadata()
.tool
.as_ref()
.and_then(|tool| tool.uv.as_ref())
.and_then(|uv| uv.exclude_dependencies.as_ref())
.into_iter()
.flatten()
.cloned()
.collect::<Vec<_>>();

Ok(Some(RequirementsSpecification::from_overrides(
Ok(Some(RequirementsSpecification::from_excludes(
requirements,
constraints,
overrides,
excludes,
)))
}

Expand Down
37 changes: 37 additions & 0 deletions crates/uv/tests/it/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,43 @@ fn run_pep723_script_overrides() -> Result<()> {
Ok(())
}

/// Run a PEP 723-compatible script with `tool.uv` excludes.
#[test]
fn run_pep723_script_excludes() -> Result<()> {
let context = uv_test::test_context!("3.12");

let test_script = context.temp_dir.child("main.py");
test_script.write_str(indoc! { r#"
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "anyio>=3",
# ]
#
# [tool.uv]
# exclude-dependencies = ["idna"]
# ///

import anyio
"#
})?;

uv_snapshot!(context.filters(), context.run().arg("main.py"), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved 2 packages in [TIME]
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
+ anyio==4.3.0
+ sniffio==1.3.1
");

Ok(())
}

/// Run a PEP 723-compatible script with `tool.uv` build constraints.
#[test]
fn run_pep723_script_build_constraints() -> Result<()> {
Expand Down
Loading