Add [testenv] constraints option#3556
Conversation
Signed-off-by: Stephen Finucane <stephen@that.guru>
3ab1c98 to
1e2cdf0
Compare
Signed-off-by: Stephen Finucane <stephen@that.guru>
The minimum version is Python 3.9 now. Signed-off-by: Stephen Finucane <stephen@that.guru>
This allows users to override constraints files for all installations. Without this, it is not possible to use constraints files that include the package under test without introducing a separate pre-tox processing step to scrub said package from the constraints file. Signed-off-by: Stephen Finucane <stephen@that.guru>
|
Can you explain how this differs from just setting the PIP_Constraint environment variable via set env? |
|
Sure. Consider https://github.com/openstack/openstacksdk. Like all OpenStack projects, it uses constraints to ensure co-installability. We currently pass the diff --git tox.ini tox.ini
index ca14f55af..3c6e6d6a1 100644
--- tox.ini
+++ tox.ini
@@ -15,8 +15,8 @@ setenv =
OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
+ PIP_CONSTRAINT={env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
deps =
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands =I then run This will always happen if you are developing a project that is itself included in constraints file, which is neither uncommon nor unreasonable (IMO) since those projects need to evolve too. I considered simply ignoring the Suggesting I lose the ability to auto-regenerate when constraints change, which tox (4) is otherwise very good at. Thus, here is my proposed solution. An alternative would be to ignore |

Pushing as draft to ensure this is a sane direction. I still need to add tests. I also think I should subclassPythonConstraintsfromRequirementsFilerather thanPythonDepssince we don't need a lot of the logic in the latter.I've done both of these now.
Add a new option allowing us to specify constraints file(s) that will be applied when installing all dependencies except the package under test. For example, given the following
tox.ini:The all requirements in
deps, all requirements in thetestextra, and all dependencies of the package itself will be installed with-c upper-constraints.txt. The package itself will not.Closes #3550
tox -e fix)docs/changelogfolder