How to install Python dependencies in a project¶
Your Divio Cloud project has a
requirements.in file, processed by the
pip-compile command from pip-tools.
Place your dependencies in the file, making sure that they are outside the:
# <INSTALLED_ADDONS>... # </INSTALLED_ADDONS>
tags, since that part of the file is maintained automatically and is overwritten automatically with the requirements from the Addons system.
Wherever possible, pin your dependencies
An unpinned dependency is a hostage to fortune, and is highly likely to break something without warning when a new release is made.
Unpinned dependencies are the number one cause of deployment failures. Nothing in the codebase may have changed, but a fresh deployment can unexpectedly pick up a newly-released version of a package.
Sometimes your dependencies may themselves have unpinned dependencies. In this case, it can be worth explicitly pinning those too.
When installing from a version control repository, it is strongly recommended to pin the package by specifying a tag or commit, rather than branch.
Installing from PyPI¶
Use the package name, pinned with an optional (but very strongly recommended) version number, for example:
Installing from an online package or version control system¶
You can use the URL of a tarballed or zipped archive of the package, typically provided by a version control system.
Examples from GitHub¶
Master branch, as tarball:
or as a zipped archive:
Specify a different branch:
However, we very strongly recommend specifying either a tag:
or a commit:
pip set-up does not support VCS protocols - you cannot use for
example URLs starting
hg+, such as
However, as long as the version control system host offers full package downloads, you can use the tarball or zip archive URL for that to install from the VCS, as in the examples above.
Rebuild the Docker container¶
To rebuild the Docker container, installing the new dependencies:
docker-compose build web