Skip to content

Dependency management

We track dependencies with Poetry dependency management tool, which:

  • Tracks both python version and dependencies in a pyproject.toml file
  • Tracks all dependency versions in a .lock file so the environment is reproducible, i.e. if pip+requirements.txt specify only fastapi==0.80.0, .lock file will specify the dependencies of fastapi too
  • Adds new dependencies or removes them as soon as you add/uninstall them in the environment: no need to manually type in dependency names as with pip
  • Tries to resolve dependency conflicts
  • Allows to create environments and manage packages in special poetry shell

Here's the installation guide. with several installation methods. If the official installer fails, use the pipx method instead.

Poetry and Pycharm

Pycharm supports poetry so there’s no additional overhead when using it for creating environments.

Start with reading poetry documentation and RealPython article to make sure that you are familiar with basic operations. Here are some important points to consider:

  • When creating an application, commit the .lock file. This will result in a more stable and reproducible environment.
  • Use groups while adding packages. For most projects this will include:
    • tool.poetry.dependencies - the packages essential for the main functionality of the project
    • tool.poetry.group.dev.dependencies - the dependencies used during the development, like pytest and pylint
    • tool.poetry.group.docs.dependencies - dependencies for documentation like mkdocs
  • The groups might be optional, i.e. you would need to install them explicitly: poetry install --with docs:
[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
mkdocs = "*"