Skip to content

Commit

Permalink
Add script support to feature highlights in index
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Aug 20, 2024
1 parent 3395d24 commit 0b053ca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/getting-started/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ See the [guide on installing Python](../guides/install-python.md) to get started
Executing standalone Python scripts, e.g., `example.py`.

- `uv run`: Run a script.
- `uv add --script`: Add a dependency to a script
- `uv remove --script`: Remove a dependency from a script

See the [guide on running scripts](../guides/scripts.md) to get started.

Expand Down
26 changes: 25 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ An extremely fast Python package and project manager, written in Rust.
- ⚡️ [10-100x faster](https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md) than `pip`.
- 🐍 [Installs and manages](#python-management) Python versions.
- 🛠️ [Runs and installs](#tool-management) Python applications.
- ❇️ [Runs scripts](./guides/scripts.md), with support for
- ❇️ [Runs scripts](#script-support), with support for
[inline dependency metadata](./guides/scripts.md#declaring-script-dependencies).
- 🗂️ Provides [comprehensive project management](#project-management), with a
[universal lockfile](./concepts/projects.md#lockfile).
Expand Down Expand Up @@ -158,6 +158,30 @@ Pinned `.python-version` to `[email protected]`

See the [installing Python guide](./guides/install-python.md) to get started.

### Script support

uv manages dependencies and environments for single-file scripts.

Create a new script and add inline metadata declaring its dependencies:

```console
$ echo 'import requests; print(requests.get("https://astral.sh"))' > example.py

$ uv add --script example.py requests
Updated `example.py`
```

Then, run the script in an isolated virtual environment:

```
$ uv run example.py
Reading inline script metadata from: example.py
Installed 5 packages in 12ms
<Response [200]>
```

See the [scripts guide](./guides/scripts.md) to get started.

## The pip interface

uv provides a drop-in replacement for common `pip`, `pip-tools`, and `virtualenv` commands.
Expand Down

0 comments on commit 0b053ca

Please sign in to comment.