[Pytest-commit] Issue #296: support tracking changes in requirements.txt without full rebuild (hpk42/tox)

Maxim Kovgan issues-reply at bitbucket.org
Wed Dec 16 10:51:00 EST 2015


New issue 296: support tracking changes in requirements.txt without full rebuild
https://bitbucket.org/hpk42/tox/issues/296/support-tracking-changes-in

Maxim Kovgan:

h4. Use case:
during the development, you often switch between new and old requirements.
This currently forces the user to run `tox -r`
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.

h4. 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)

h3. Scope
only handle 4 situations, nothing else

h3. implementation:

Let's use `difflib` module's functionality: it already has `ndiff()` seemingly very useful for this purpose.
based on that diff we should generate 2 lists:
# packages_to_remove
# packages_to_install

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 `-I` option (i.e. older will be uninstalled)


A very easy to implement code can take existing, current pip freeze output and compare it to requirements.txt to be used.
As a result, if there are diffs (lines with "-" and lines with "+"), those with "-" can be uninstalled, and those with "+" - installed.
This would automatically resolve problems of full virtualenv recreation of 




More information about the pytest-commit mailing list