Add --script support to uv tree for PEP 723 scripts (#10159)

## Summary

You can now run `uv tree --script main.py` to show the dependency tree
for a given script. If a lockfile doesn't exist, it will create one.

Closes https://github.com/astral-sh/uv/issues/7328.
This commit is contained in:
Charlie Marsh 2025-01-08 16:32:46 -05:00 committed by GitHub
parent 31b2d3f988
commit 9d5779b68c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 483 additions and 13 deletions

View file

@ -3437,6 +3437,14 @@ pub struct TreeArgs {
#[command(flatten)]
pub resolver: ResolverArgs,
/// Show the dependency tree the specified PEP 723 Python script, rather than the current
/// project.
///
/// If provided, uv will resolve the dependencies based on its inline metadata table, in
/// adherence with PEP 723.
#[arg(long)]
pub script: Option<PathBuf>,
/// The Python version to use when filtering the tree.
///
/// For example, pass `--python-version 3.10` to display the dependencies