I'm co-developing a CLI for https://pretextbook.org/ authors. When an author runs pretext new
we generate boilerplate files for their new project, including a requirements.txt
that matches the current version of the CLI. If the author updates their CLI package, their project's source files may no longer be compatible with the updated package. Is there a canonical way to parse a requirements.txt
file and print out a warning that the CLI version being used does not match the version set in requirements.txt
?
If I wanted to parse requirements file like pip, I'd use pip-requirements-parser, since pip itself can't easily be used as a library, and pip-requirements-parser claims to be as close to pip as possible.
On another hand, I don't think you need that at all. If user is expected to edit requirements file, then you can't really deduce anything from these versions.
Consider this:
requirements.txt
contains pretext==1.2.3
pretext>=1.2.3
requirements.txt
specification.Hence you need another solution, like a dedicated .pretext_project_version
file, so you can reasonably expect user to not confuse project requirements and compatible CLI version. This would also simplify project versioning for yourself, because you'll have to bump that version only on incompatible changes, rather than encode logic like "project v 1.0 is compatible with 1.5 and 2.0, but not 2.2"