DEVELOPMENT | PYTHON | DATA SCIENCE
Just about any Python developer from beginner to expert has heard about the
requirements.txt file. It documents our package dependencies for Python, and it can be version controlled along with our code.
requirements.txt file might look something like this:
[ . . . ]
However, I’d like to introduce a simple but effective concept for long-term maintenance of Python repositories — the
Most Python developers only intend to use a handful of packages in their project, and the rest of the packages listed in
requirements.txt are sub-dependencies. Personally, I haven’t heard of at least half of the packages that show up in a given
requirements.txt file that I’ve generated.
Additionally, most Python developers don’t care about the version of a package they’re using unless:
- The package is out of date
- The package has a version conflict with another package
- Certain feature(s) are only available in specific version(s) of a package
We’ll refer to the full, explicit list of dependencies that our project needs in the absolute requirements. We’ll refer to the packages that we’re truly cognizant of the core requirements.
requirements-core.txt file is simply a list of package dependencies that is stripped down to the core requirements of a project, minus any version number hints.
Let’s imagine these three files exist in our project…
#!/bin/bashpip install -r requirements-core.txt
pip freeze > requirements.txt
As demonstrated above, a project with 5 core requirements (
requests) ultimately had 21 absolute requirements.
Six months (or multiple years) down the road, most or all of the maintainers of this project would have forgotten what the core requirements were if they weren’t documented elsewhere.
By extracting the core requirements from our absolute…
Continue reading: https://towardsdatascience.com/why-you-should-consider-adding-requirements-core-txt-to-your-next-python-project-2c36c1381b12?source=rss—-7f60cf5620c9—4