In uv, project dependency specification is divided between two `pyproject.toml` tables: `project.dependencies` and
`tool.uv.sources`.
`project.dependencies` is used to define the standards-compliant dependency metadata,
propagated when uploading to PyPI or building a wheel. `tool.uv.sources` is used to specify the _sources_
required to install the dependencies, which can come from a Git repository, a URL, a local path, a
different index, etc. This metadata must be expressed separately because the `project.dependencies` standard does not allow these common patterns.
## Project dependencies
The `project.dependencies` table represents the dependencies that are used when uploading to PyPI or
building a wheel. Individual dependencies are specified using [PEP 508](#pep-508) syntax, and the table follows the [PEP 621](https://packaging.python.org/en/latest/specifications/pyproject-toml/)
standard.
`project.dependencies` defines the packages that are required for the project, along with the version constraints that should be used when installing them.
`project.dependencies` is structured as a list. Each entry includes a dependency name and
version. An entry may include extras or environment markers for platform-specific packages. For example:
If the project only requires packages from standard package indexes, then `project.dependencies` is sufficient. If, the project depends on packages from Git, remote URLs, or local sources, `tool.uv.sources` is needed.
Git dependencies can also be manually added or edited in the `pyproject.toml` with the `{ git = <url> }` syntax. A target revision may be specified with one of: `rev`, `tag`, or `branch`. A `subdirectory` may be specified if the package isn't in the repository root.
### URL
To add a URL source, provide a `https://` URL to either a wheel (ending in `.whl`) or a source distribution (ending in `.zip` or `.tar.gz`).
URL dependencies can also be manually added or edited in the `pyproject.toml` with the `{ url = <url> }` syntax. A `subdirectory` may be specified if the if the source distribution isn't in the archive root.
### Path
To add a path source, provide the path of a wheel (ending in `.whl`), a source distribution (ending in `.zip` or `.tar.gz`), or a directory containing a `pyproject.toml`.
For example:
```console
$ uv add /example/foo.whl
```
Will result in a `pyproject.toml` with:
```toml title="pyproject.toml"
[project]
dependencies = [
"foo",
]
[tool.uv.sources]
foo = { path = "/example/foo.whl" }
```
The path may also be a relative path, e.g.:
```console
$ uv add ./foo
```
Note an [editable installation](#editables-dependencies) is not used for path dependencies. However, for directories, an editable installation may be requested, e.g.:
```console
$ uv add --editable ./foo
```
However, it is recommended to use [_workspaces_](#workspaces) instead of manual path dependencies.
### Workspace member
To declare a workspace member, add the dependency with `{ workspace = true }`. All workspace members must be explicitly stated. Workspace members are [editable](#editables-dependencies) by default; `editable = false` may be included to install them as regular dependencies. See the [workspace](./workspaces.md) documentation for more details on workspaces.
It is common for projects that are published as libraries to make some features optional to reduce the default dependency tree. For example,
Pandas has an [`excel` extra](https://pandas.pydata.org/docs/getting_started/install.html#excel-files)
and a [`plot` extra](https://pandas.pydata.org/docs/getting_started/install.html#visualization) to avoid installation of Excel parsers and `matplotlib` unless someone explicitly requires them. Extras are requested with the `package[<extra>]` syntax, e.g., `pandas[plot, excel]`.
Optional dependencies are specified in `[project.optional-dependencies]`, a TOML table that maps
from extra name to its dependencies, following [PEP 508](#pep-508) syntax.
Optional dependencies can have entries in `tool.uv.sources` the same as normal dependencies.
Unlike optional dependencies, development dependencies are local-only and will _not_ be included in the project requirements when published to PyPI or other indexes. As such, development dependencies are included under `[tool.uv]` instead of `[project]`.
Development dependencies can have entries in `tool.uv.sources` the same as normal dependencies.
Markers are combined with `and`, `or`, and parentheses, e.g., `aiohttp >=3.7.4,<4; (sys_platform != 'win32' or implementation_name != 'pypy') and python_version >= '3.10'`.
Note that versions within markers must be quoted, while versions _outside_ of markers must _not_ be
quoted.
## Editable dependencies
A regular installation of a directory with a Python package first builds a wheel and then installs
that wheel into your virtual environment, copying all source files. When the package source files are edited,
the virtual environment will contain outdated versions.
Editable installations solve this problem by adding a link to the project within the virtual environment
(a `.pth` file), which instructs the interpreter to include the source files directly.
There are some limitations to editables (mainly: the build backend needs to support them, and
native modules aren't recompiled before import), but they are useful for development, as the
virtual environment will always use the latest changes to the package.