Dependencies in this project are managed using pip-compile and pip-sync (from pip-tools).
Direct production/release dependencies are specified in requirements.in
(which is manually
edited). These are pinned to a specific version to make it easier to control
and track upgrades to direct dependencies. A small number of indirect dependencies are also
included in requirements.in
where we have previously had breakages caused by updates to
those libraries.
requirements.txt
is a lock file generated using pip-compile and should not be manually edited.
Anything that does not need to be in production should be inluded within the requirments-dev.in
(which is manually edited). The requirements-dev.txt
is the local generated lock file and is what will be released for circle-ci but the staging/releasable environments should be setup like production, with a reduced footprint.
Dependencies should always be installed using requirements.txt
. The first time you do this,
you should run:
pip install -r requirements.txt
After that, you can run pip-sync
instead.
(Note that pip-sync will also remove any installed dependencies that are not specified in the
lock file, such as removed dependencies or packages manually installed using pip.)
-
Add the package to the relevant section in
requirements.in
, specifying a particular version (typically the latest at time of adding). -
Run
pip-compile --upgrade --output-file requirements.txt requirements.in
to regeneraterequirements.txt
. Note: This will also update indirect dependencies. -
Run
pip-sync
to install the new locked dependencies locally. (You can also usepip install -r requirements.txt
, but that may leave behind redundant packages that have been removed which can cause problems.) -
Commit the changes as part of your feature branch.
-
Check for out-of-date dependencies. You can use piprot for this by running
piprot -o requirements.in
. Alternatively, you can use pip by runningpip list -o
. -
Update the versions in
requirements.in
to the new desired versions. Make sure you check the change logs for dependencies that are being updated in case they have any breaking changes. -
Run
pip-compile --upgrade --output-file requirements.txt requirements.in
to regeneraterequirements.txt
. Note that this will also update indirect dependencies. -
Run
pip-sync
to install the new locked dependencies locally. (You can also usepip install -r requirements.txt
, but that may leave behind redundant packages that have been removed which can cause problems.) -
Create a PR. Include links to the change logs for dependencies in
requirements.in
that were updated to make it easier for other developers to have a look at them.