Skip to content

Commit

Permalink
Use uv add --script in guide (#6215)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Aug 19, 2024
1 parent a1f98e2 commit 39c3c01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/guides/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ Python recently added a standard format for
[inline script metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata).
This allows the dependencies for a script to be declared in the script itself.

To use inline script metadata, include a `script` section at the top of the script and declare the
dependencies using TOML:
uv supports adding and updating inline script metadata for you. Use `uv add --script` to declare the
dependencies for the script:

```console
$ uv add --script example.py 'requests<3' 'rich'
```

This will add a `script` section at the top of the script declaring the dependencies using TOML:

```python title="example.py"
# /// script
Expand Down

0 comments on commit 39c3c01

Please sign in to comment.