Test `pipreqs` to obtain requirements from code base
ruestefa opened this issue · 0 comments
I recently stumbled upon pipreqs
(see #33), a tool that scans a code base and creates a requirements.txt
file. This could be useful especially for legacy projects that don't have a requirements file yet, or periodically for bigger codes to keep the requirements complete and clean. I haven't tested it, but if it works as advertised, it could be a useful addition to dev-requirements.yml
.
Since the blueprint has switched to conda YAML files for both (pinned) environments and (unpinned) requirements (#32), the output of pipreqs
would not directly useful to a project. However, the list of pinned requirements could easily be converted by hand to a format that can be diff'd against requirements.yml
to identify missing/obsolete packages in the latter, or to derive minimum versions from the pinned versions.
Possible workflow
- Run
pipreqs
, which creates arequirements.txt
- Compare this
requirements.txt
withrequirements.yml
- Insert
-
on each line - Convert the pinned dependencies (e.g.,
==1.4.2
) to minimum requirements (e.g.,>=1.4
) - Use your diff tool of choice
- Insert
- Add missing dependencies, remove obsolete ones, and add/adapt minimum versions as necessary
- Remove the
requirements.txt
TODOs
- Test
pipreqs
- If successful, add to
dev-requirements.yml
- Briefly document usage