Recreate test environment when contents of requirements files change

Issue #267 on hold
Omer Katz created an issue

Tox should recreate the environment if the contents of any of the requirement files have changed since the last run. Otherwise that causes tests to fail because the dependencies are too old.

Comments (11)

  1. Ronny Pfannschmidt

    there is currently no good way to hash potentially complex local structures (for dependencies in sibling folders and/or potentially interrelated requirements files)

    unfortunately its also not easy to write a unit-test for that behaviour

  2. Omer Katz reporter

    You should be able to do that by using pip's requirements parser to get the full list of requirements: https://github.com/pypa/pip/blob/master/pip/req/req_file.py#L57 Afterwards you should be able to use the InstallRequirement object's check_if_exists method (https://github.com/pypa/pip/blob/master/pip/req/req_install.py#L968) or similar logic to check if the requirements have changed. Alternatively you could reconstruct the full list of requirements by stringifying all InstallRequirement objects and applying a hash function on them. That will be slower though since you'll have to iterate through all requirements even if one of them has changed. A third approach would be to extract the logic that recognizes nested requirements file and apply a hash function on each of them.

    Is there something wrong with any of these approaches or am I missing something?

  3. Ronny Pfannschmidt

    the second approach is what i have in mind (hashing related requirements files)

    however creating the tools needed to properly unit-test the details is rather tricky, the problem is not in creating the code, but rather in creating a test for it that's not a system test

  4. Omer Katz reporter

    What's wrong with the other approaches I suggested? Or why is the second approach better?

  5. Ronny Pfannschmidt

    the code in question is not directly approachable - which is why unittesting it is hard

    its not impossible it just needs time, there already is a system level pr that uses pip api to resolve the requirements files, so we might be able to leave it at that (at the possiblity that a future pip update can break tox

    ideally the start would be adding a resolve command to pip that would allow to resolve packages and/or requirement files to either the requirements or the latest available versions on the index or the potential updates or to download urls

  6. Log in to comment