Skip to content

Commit

Permalink
Support PEP 723 scripts in uv add and uv remove (#5995)
Browse files Browse the repository at this point in the history
## Summary

Resolves #4667

## Test Plan

`cargo test`
  • Loading branch information
blueraft committed Aug 11, 2024
1 parent 9b8c07b commit 2d53e35
Show file tree
Hide file tree
Showing 12 changed files with 1,212 additions and 286 deletions.
17 changes: 17 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,16 @@ pub struct AddArgs {
#[arg(long, conflicts_with = "isolated")]
pub package: Option<PackageName>,

/// Add the dependency to the specified Python script, rather than to a project.
///
/// If provided, uv will add the dependency to the script's inline metadata
/// table, in adhere with PEP 723. If no such inline metadata table is present,
/// a new one will be created and added to the script. When executed via `uv run`,
/// uv will create a temporary environment for the script with all inline
/// dependencies installed.
#[arg(long, conflicts_with = "dev", conflicts_with = "optional")]
pub script: Option<PathBuf>,

/// The Python interpreter to use for resolving and syncing.
///
/// See `uv help python` for details on Python discovery and supported
Expand Down Expand Up @@ -2509,6 +2519,13 @@ pub struct RemoveArgs {
#[arg(long, conflicts_with = "isolated")]
pub package: Option<PackageName>,

/// Remove the dependency from the specified Python script, rather than from a project.
///
/// If provided, uv will remove the dependency from the script's inline metadata
/// table, in adhere with PEP 723.
#[arg(long)]
pub script: Option<PathBuf>,

/// The Python interpreter to use for resolving and syncing.
///
/// See `uv help python` for details on Python discovery and supported
Expand Down
4 changes: 1 addition & 3 deletions crates/uv-scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ uv-settings = { workspace = true }
uv-workspace = { workspace = true }

fs-err = { workspace = true, features = ["tokio"] }
indoc = { workspace = true }
memchr = { workspace = true }
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }
toml = { workspace = true }

[dev-dependencies]
indoc = { workspace = true }
Loading

0 comments on commit 2d53e35

Please sign in to comment.