Support PEP 723 scripts in uv add and uv remove (#5995)

## Summary

Resolves https://github.com/astral-sh/uv/issues/4667

## Test Plan

`cargo test`
This commit is contained in:
Ahmed Ilyas 2024-08-11 03:40:59 +02:00 committed by GitHub
parent 9b8c07bf18
commit 2d53e35e39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 1215 additions and 289 deletions

View file

@ -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
@ -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