Add --script support to uv export for PEP 723 scripts (#10160)

## Summary

You can now run `uv export --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/8609.

Closes https://github.com/astral-sh/uv/issues/9657.
This commit is contained in:
Charlie Marsh 2025-01-08 16:48:53 -05:00 committed by GitHub
parent 9d5779b68c
commit 18b53c5b45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 400 additions and 53 deletions

View file

@ -3651,6 +3651,14 @@ pub struct ExportArgs {
#[command(flatten)]
pub refresh: RefreshArgs,
/// Export the dependencies for 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, conflicts_with_all = ["all_packages", "package", "no_emit_project", "no_emit_workspace"])]
pub script: Option<PathBuf>,
/// The Python interpreter to use during resolution.
///
/// A Python interpreter is required for building source distributions to