Dependencies

The list of required Python packages for the Hub are kept in the requirements/ directory. It contains both .in files (which are user-editable) and .txt files (which are autogenerated).

  • base has common dependencies across all environments

  • docs has requirements just needed for building the documentation

  • local has the packages needed for local development

  • production has any extra packaages just required for staging or production deployment.

As many dependencies should be kept in base as possible.

The dependencies should be unpinned in the .in file.

Whenever you edit any of the .in files, you should regenerate the corresponding .txt file(s). If you edit base.in, be sure to regenerate all the other .txt files too.

Adding a new dependency

To generate dependencies, we use pip-compile. This takes the unversioned list of dependencies in the .in files and produces a pinned list of dependencies we can then use to install.

Say we have just added a new dependency, refactor_o_matic, but it is just a local dependency. After adding it to local.in, we would run:

pip-compile --output-file=requirements/local.txt requirements/local.in

You can then install the up to date requirements/local.txt file with:

pip-sync requirements/local.txt

Updating dependencies

If you wish to update the packages in a .in file, run pip-compile with a -U:

pip-compile --output-file=requirements/local.txt requirements/local.in -U

If you’re updating requirements in the local package list, you should update for production too:

pip-compile --output-file=requirements/production.txt requirements/production.in -U

Make sure that after doing this, you re-run the test suite and fix any failing tests.

Convenience commands

There is a convience command available using npm to regenerate all dependency files (without updating them):

npm run pip-compile

And to run pip-sync with the local requirements file:

npm run pip-sync