We support the following sources (which are mutually exclusive for a given dependency):
- Git: Use `git` with a Git URL, optionally one of `rev`, `tag`, or `branch`, and
optionally a `subdirectoy`, if the package isn't in the repository root.
- URL: A `url` key with an `https://` URL to a wheel (ending in `.whl`) or a source distribution
(ending in `.zip` or `.tar.gz`), and optionally a `subdirectory` if the source distribution isn't
in the archive root.
- Path: The `path` is an absolute or relative path to a wheel (ending in `.whl`), a source
distribution (ending in `.zip` or `.tar.gz`), or a directory containing a `pyproject.toml`. We
recommend using workspaces over manual path dependencies. For directories, you can specify
`editable = true` for an [editable](#Editables) installation.
- Index: Set the `index` key to the name of an index name to install it
from this registry instead of your default index.
- Workspace: Set `workspace = true` to use the workspace dependency. You need to explicitly require
all workspace dependencies you use. They are [editable](#Editables) by default; specify
`editable = false` to install them as regular dependencies.
Note that if a non-uv project uses this project as a Git- or path-dependency, only
`project.dependencies` is transferred, and you'll need to apply the information in the source table
using the configuration of the other project's package manager.
## Optional dependencies
For libraries, you may want to make certain features and their dependencies optional. 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 limit the installation of Excel parsers and (e.g.) `matplotlib` to
those that explicitly require them. In the case of Pandas, you can install those extras with:
`pandas[plot, excel]`.
Optional dependencies are specified in `[project.optional-dependencies]`, a TOML table that maps
from extra name to its dependencies, following the [PEP 508](#PEP 508) syntax.
`tool.uv.sources` applies to this table equally.
```toml
[project]
name="pandas"
version="1.0.0"
[project.optional-dependencies]
plot=[
"matplotlib>=3.6.3"
]
excel=[
"odfpy>=1.4.1",
"openpyxl>=3.1.0",
"python-calamine>=0.1.7",
"pyxlsb>=1.0.10",
"xlrd>=2.0.1",
"xlsxwriter>=3.0.5"
]
```
## Development dependencies
_N.B. This feature is not yet implemented._
Unlike optional dependencies, development dependencies are local-only and will _not_ be published
to PyPI or other indexes. As such, development dependencies are included under `[tool.uv]` instead
of `[project]`. `tool.uv.sources` applies to them equally.
```toml
[tool.uv]
dev-dependencies=[
"pytest >=8.1.1,<9"
]
```
You can also put development dependencies into groups and install them individually:
```toml
[tool.uv.dev-dependencies]
test=[
"pytest >=8.1.1,<9"
]
lint=[
"mypy >=1,<2"
]
[tool.uv]
default-dev-dependencies=["test"]
```
## PEP 508
The [PEP 508](https://peps.python.org/pep-0508/) syntax allows you to specify, in order:
You combine markers with `and` 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.
## Editables
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 you edit the source files,
the virtual environment will contain outdated versions.
Editable installations instead add a link to the project within the virtual environment
(a `.pth` file), which instructs the interpreter to include your sources directly.
There are some limitations to editables (mainly: your build backend needs to support them, and
native modules aren't recompiled before import), but they are useful for development, as your
virtual environment will always use the latest version of your package.
uv uses editable installation for workspace packages and patched dependencies by default.