# Adding dependencies per "Packaging Python Projects"

**URL:** <https://discuss.python.org/t/adding-dependencies-per-packaging-python-projects/14048>\
**Category:** Packaging\
**Created:** [March 3, 2022, 9:30pm UTC](https://discuss.python.org/t/adding-dependencies-per-packaging-python-projects/14048 "2022-03-03T21:30:15Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 3, 2022, 11:04pm UTC](https://discuss.python.org/t/adding-dependencies-per-packaging-python-projects/14048/6 "2022-03-03T23:04:24Z")

</div>

> [@rockobonaparte](#):
>
> I was testing it by installing it into an empty virtualenv, and then running pip freeze in that environment to verify whether or not it was there. The only thing that shows up after installing is the package itself that I installed.

FYI, `pip list` is the command to run to see what’s currently installed in your environment.

> [@rockobonaparte](#):
>
> The only thing that shows up after installing is the package itself that I installed.

Presumably, the dependency wasn’t listed under the appropriate key for listing run-time requirements for your chosen build backend (e.g. `install_requires` under `[metadata]` in `setup.cfg` for Setuptools, `dependencies` under `[project]` in `pyproject.toml` for the new format specified in [PEP 621](https://www.python.org/dev/peps/pep-0621/)).

If you only listed your dependencies in a `requirements.txt` file, it will not be installed automatically. The use of `requirements.txt` files (often generated by `pip freeze` or `pip-tools`) is generally for manual installation for development and applications that need to reproduce a given environment exactly, or other specialized applications, and must be manually specified by e.g. `pip install -r requirements.txt`.

> [@jwodder](#):
>
> > [@rockobonaparte](#):
> >
> > Do I actually still need to use a setup.py if I have requirements?
> 
> No. If you’re using setuptools, you can specify the requirements in `setup.cfg` :

To elaborate, in reasonably recent versions of Setuptools, you can [decoratively specify your metadata and build config in a static setup.cfg](https://setuptools.pypa.io/en/stable/userguide/declarative_config.html). This is simpler, much harder to mess up and has many benefits over using a dynamic `setup.py` file for the same purpose, and [tools exist](https://github.com/asottile/setup-cfg-fmt) to convert the latter to the former. While in recent-enough Setuptools you can omit the `setup.py` completely, its probably best to retain a stub setup.py for now, e.g.

```python
#!/usr/bin/env python3

"""Stub setup.py for use with legacy build tooling."""

import setuptools

if __name__ == " __main__":
    setuptools.setup()

```

to accommodate legacy tooling and use cases.

Furthermore, forthcoming versions of Setuptools will gain support for specifying dependencies in the PEP 621-specified `[project]` table of `pyproject.toml`, which will work with _any_ build backend (Flit, Setuptools, Poetry, PDM, Hatch, etc) once they support it (which with Setuptools adding support, leaves Poetry as the main laggard here).

```ini
[project]
dependencies = [
    "json5 >= 0.9.6",
]

```

> [@Help testing experimental features in setuptools](https://discuss.python.org/t/help-testing-experimental-features-in-setuptools/13821):
>
> Hello all. For the past months we have been experimenting with adding some features to setuptools, specially the support for project metadata in pyproject.toml (initially introduced in PEP 621). Other features complement it: automatic layout discovery (for flat, src or single-module layouts), defaulting to include\_package\_data=True, etc… The idea is to make the [tool.setuptools] table in pyproject.toml not necessary that for the simple use cases. If anyone is interested in helping testing the…

---

_[View the full topic](https://discuss.python.org/t/adding-dependencies-per-packaging-python-projects/14048)._
