db371560bc
To enforce the 100 character line limit in markdown files introduced in https://github.com/astral-sh/uv/pull/5635, and to automate the formatting of markdown files, i've added prettier and formatted our markdown files with it. I've excluded the changelog and the generated references documentation from this for having too many changes, but we can also include them. I'm not particular on which style we use. My main motivations are (major) not having to reflow markdown files myself anymore and (minor) consistence between all markdown files. I've chosen prettier for similar reason as we chose black, it's a single good style that's automated and shared in the community. I do prefer prettier's style of not breaking inside of a link name though. This PR is in two parts, the first adds prettier to CI and documents using it, while the second actually formats the docs. When merge conflicts arise, we can drop the last commit and regenerate it with `npx prettier --prose-wrap always --write BENCHMARKS.md CONTRIBUTING.md README.md STYLE.md docs/*.md docs/concepts/**/*.md docs/guides/**/*.md docs/pip/**/*.md`. --------- Co-authored-by: Zanie Blue <contact@zanie.dev>
54 lines
1.6 KiB
Markdown
54 lines
1.6 KiB
Markdown
# Declaring dependencies
|
|
|
|
It is best practice to declare dependencies in a static file instead of modifying environments with
|
|
ad-hoc installations. Once dependencies are defined, they can be [locked](./compile.md) to create a
|
|
consistent, reproducible environment.
|
|
|
|
## Using `pyproject.toml`
|
|
|
|
The `pyproject.toml` file is the Python standard for defining configuration for a project.
|
|
|
|
To define project dependencies in a `pyproject.toml` file:
|
|
|
|
```toml title="pyproject.toml"
|
|
[project]
|
|
dependencies = [
|
|
"httpx",
|
|
"ruff>=0.3.0"
|
|
]
|
|
```
|
|
|
|
To define optional dependencies in a `pyproject.toml` file:
|
|
|
|
```toml title="pyproject.toml"
|
|
[project.optional-dependencies]
|
|
cli = [
|
|
"rich",
|
|
"click",
|
|
]
|
|
```
|
|
|
|
Each of the keys defines an "extra", which can be installed using the `--extra` and `--all-extras`
|
|
flags or `package[<extra>]` syntax. See the documentation on
|
|
[installing packages](./packages.md#installing-packages-from-files) for more details.
|
|
|
|
See the official
|
|
[`pyproject.toml` guide](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) for
|
|
more details on getting started with a `pyproject.toml`.
|
|
|
|
## Using `requirements.in`
|
|
|
|
It is also common to use a lightweight `requirements.txt` format to declare the dependencies for the
|
|
project. Each requirement is defined on its own line. Commonly, this file is called
|
|
`requirements.in` to distinguish it from `requirements.txt` which is used for the locked
|
|
dependencies.
|
|
|
|
To define dependencies in a `requirements.in` file:
|
|
|
|
```text title="requirements.in"
|
|
httpx
|
|
ruff>=0.3.0
|
|
```
|
|
|
|
Optional dependencies groups are not supported in this format.
|