Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions package-structure-code/declare-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ dependencies in your `pyproject.toml`.
(package-dependencies)=
## What is a package dependency?

A Python package dependency refers to an external package or
A tool that is needed when using or working on your Python project. Declare your dependencies in your `pyproject.toml` file. This keeps all package metadata in one place, making it simpler for users and contributors to understand your package.
A Python package dependency refers to an external package or a tool that is needed
when using or working on your Python project. Declare your dependencies in
your `pyproject.toml` file. This keeps all package metadata in one place, making
it simpler for users and contributors to understand your package.

:::{admonition} Older ways to declare dependencies
:class: tip
Expand All @@ -30,7 +32,7 @@ While `pyproject.toml` is now the standard, you may sometimes encounter older ap
### Why specify dependencies

Specifying dependencies in the `project.dependencies` array of your `pyproject.toml` file ensures that libraries needed to run your package are correctly installed into a user's environment.
For instance, if your package requires Pandas to run properly, and you add Pandas to the `project.dependencies` array, Pandas will be installed into the users' environment when they install your package using uv, pip, or conda.
For instance, if your package requires pandas to run properly, and you add pandas to the `project.dependencies` array, pandas will be installed into the user's environment when they install your package using uv, pip, or conda.

```toml
[project]
Expand Down Expand Up @@ -190,7 +192,7 @@ locally. They are used to perform tasks such as:

Dependency groups are optional because they are not required for users
to install and use your package. However, they will make it easier for
contributors to your project to setup development environments
contributors to your project to set up development environments
locally.

:::{admonition} New: PEP 735 dependency groups
Expand Down Expand Up @@ -318,7 +320,7 @@ $ uv sync --active --group docs
**Install optional dependencies:**

```console
# uv pip install is not idea if you are using uv supported venvs for your project
# uv pip install is not ideal if you are using uv supported venvs for your project
$ uv pip install -e ".[docs]" # Single group
$ uv pip install -e ".[docs,tests,lint]" # Multiple groups
```
Expand Down Expand Up @@ -397,7 +399,7 @@ python -m pip install ".[dev]"
```

:::{tip}
When you install optional dependencies, pip and uv install your
When you install optional dependencies, pip and uv install your
package and its core dependencies automatically.
:::

Expand Down Expand Up @@ -631,7 +633,7 @@ There is some maintenance cost from lock files. Maintainers should aim to update
the lock file neither too rarely nor too often.
* Too rarely means you risk missing updates with bugfixes, security patches,
performance improvements, etc.
* Too often means you may introduce bugs or even security vulnerablilites before
* Too often means you may introduce bugs or even security vulnerabilities before
maintainers of your dependencies catch them. Package managers are starting to
support dependency cooldowns to mitigate this.

Expand Down
Loading