Notes
Switching From Python requirements.txt to pyproject.toml
In python, a lot of projects are switching over from the old
requirements.txt format of declaring dependencies to pyproject.toml and
others. pyproject.toml can condense multiple requirements-*.txt files as
well as other package metadata into a single file, simplifying several package
maintenance processes.
The steps to switch are:
Create a bare bones
pyproject.tomlfile in the root of your package:[project] name = "<NAME>" version = "<VERSION>" dependencies = [ "dependency1", "dependency2", ]Copy a name and version from your
setup.pyif you’re still using that. Copy dependencies from yourrequirements.txt. Dependencies inpyproject.tomlfollow the same format asrequirements.txtand support dependency versioning with==,>=, and<limits.If you’ve split your
requirements-test.txtor other types of dependencies, you can include them in yourpyproject.tomlas optional dependencies:[project] ... [project.optional-dependencies] test = [ "dependency3", "dependency4", ]Delete your
requirements.txt. Hopefully you’re using version control.Switch your build commands from
pip install -r requirements.txttopip install -e .. If you want to install optionaltestdependencies too, you can do that withpip install -e .[test].