Working with the requirements.txt file
Different projects can have different dependency needs to run. That’s why we use the requirements.txt
file to capture all the third-party packages installed and used in a project. But as projects grow, we can realize that some of the dependency packages are useful only while we are developing locally, some are useful in our CI pipeline, and some are used only for production. Hence it is important that we break our requirements.txt
file into multiple parts.
We need to split our requirements.txt
file into multiple files that would be used for different purposes. This is common in large projects and is always better to implement as soon as we create a new project. This ensures that only the actually used packages are shipped to production.
Here is a structure seen in most large projects:
requirements-base.txt
– This file contains all the common third-party packages that are used in all the environments. For example, Django...