during the development, you often switch between new and old requirements.
This currently forces the user to run
Sometimes it's not serious, but for automated tests in CI, using internet - it can be several minutes overhead of ~5 or even more minutes. This becomes problematic for short builds: test suite that runs 1 minutes is waiting for tox ~5 minutes.
scenarios I'd like to handle are:
- addition of new packages
- removal of currently installed packages
- upgrade of existing package(s)
- downgrade of existing package(s)
only handle 4 situations, nothing else
difflib module's functionality: it already has
ndiff() seemingly very useful for this purpose.
based on that diff we should generate 2 lists:
Testing should be done first on the function that properly detects what needs to be removed and what needs to be installed.
- Initially - just remove anything that is changed, and install it from scratch
- later - we might want to optimize:
- packages to remove - to contain packages that are supposed to be removed or downgraded
- packages to install - should contain packages that are supposed to be installed or upgraded with
-Ioption (i.e. older will be uninstalled)
A relatively easy to implement approach would be to compare:
. current pip freeze output (on the left)
requirements.txt (on the right)
As a result, if there are diffs (lines with "-" and lines with "+"), those with "-" can be uninstalled, and those with "+" - installed.