Files
uv/docs/pip/packages.md
T

123 lines
2.5 KiB
Markdown
Raw Normal View History

2024-06-26 12:28:42 -04:00
# Managing packages
## Installing a package
To install a package into the virtual environment, e.g., Flask:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install flask
2024-06-26 12:28:42 -04:00
```
To install a package with optional dependencies enabled, e.g., Flask with the "dotenv" extra:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install "flask[dotenv]"
2024-06-26 12:28:42 -04:00
```
To install multiple packages, e.g., Flask and Ruff:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install flask ruff
2024-06-26 12:28:42 -04:00
```
To install a package with a constraint, e.g., Ruff v0.2.0 or newer:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install 'ruff>=0.2.0'
2024-06-26 12:28:42 -04:00
```
To install a package at a specific version, e.g., Ruff v0.3.0:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install 'ruff==0.3.0'
2024-06-26 12:28:42 -04:00
```
To install a package from the disk:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install "ruff @ ./projects/ruff"
2024-06-26 12:28:42 -04:00
```
To install a package from GitHub:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install "git+https://github.com/astral-sh/ruff"
2024-06-26 12:28:42 -04:00
```
To install a package from GitHub at a specific reference:
2024-08-03 08:41:33 -05:00
```console
$ # Install a tag
$ uv pip install "git+https://github.com/astral-sh/ruff@v0.2.0"
2024-06-26 12:28:42 -04:00
2024-08-03 08:41:33 -05:00
$ # Install a commit
$ uv pip install "git+https://github.com/astral-sh/ruff@1fadefa67b26508cc59cf38e6130bde2243c929d"
2024-06-26 12:28:42 -04:00
2024-08-03 08:41:33 -05:00
$ # Install a branch
$ uv pip install "git+https://github.com/astral-sh/ruff@main"
2024-06-26 12:28:42 -04:00
```
See the [Git authentication](../configuration/authentication.md#git-authentication) documentation
for installation from a private repository.
2024-06-26 12:28:42 -04:00
## Editable packages
Editable packages do not need to be reinstalled for change to their source code to be active.
To install the current project as an editable package
2024-08-03 08:41:33 -05:00
```console
$ uv pip install -e .
2024-06-26 12:28:42 -04:00
```
To install a project in another directory as an editable package:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install -e ruff @ ./project/ruff
2024-06-26 12:28:42 -04:00
```
## Installing packages from files
Multiple packages can be installed at once from standard file formats.
Install from a `requirements.txt` file:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install -r requirements.txt
2024-06-26 12:28:42 -04:00
```
See the [`uv pip compile`](./compile.md) documentation for more information on `requirements.txt`
files.
2024-06-26 12:28:42 -04:00
Install from a `pyproject.toml` file:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install -r pyproject.toml
2024-06-26 12:28:42 -04:00
```
Install from a `pyproject.toml` file with optional dependencies enabled, e.g., the "foo" extra:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install -r pyproject.toml --extra foo
2024-06-26 12:28:42 -04:00
```
Install from a `pyproject.toml` file with all optional dependencies enabled:
2024-08-03 08:41:33 -05:00
```console
$ uv pip install -r pyproject.toml --all-extras
2024-06-26 12:28:42 -04:00
```
## Uninstalling a package
To uninstall a package, e.g., Flask:
2024-08-03 08:41:33 -05:00
```console
$ uv pip uninstall flask
2024-06-26 12:28:42 -04:00
```
To uninstall multiple packages, e.g., Flask and Ruff:
2024-08-03 08:41:33 -05:00
```console
$ uv pip uninstall flask ruff
2024-06-26 12:28:42 -04:00
```