In my tox.ini
file, the dependencies are installed via the requirements.txt
file which is also used by setup.py
, as follows:
The requirements.txt
file contains the acceptable range of django
packages, depending on the python version installed, as follows:
Django>=1.11,<2 ; python_version == '2.7'
Django>=1.11,<3 ; python_version > '3'
For python3, I want to make sure the tests run on django 2.0
as well as the latest django 2.1+
that will be installed by default, obeying the version constraints specified in the requirements.txt
file. To achieve that, I force the installation of the desired django version with commands, as follows:
[tox]
envlist = {py27,py3}-django111,py3-django{20,21}
[testenv]
deps =
-r{toxinidir}/requirements.txt
commands =
django111: pip install 'Django>=1.11,<1.12'
py3-django20: pip install 'Django>=2.0,<2.1'
py3-django21: pip install 'Django>=2.1'
pytest
Ideally I could just add to the deps
variable like so:
[testenv]
deps =
-r{toxinidir}/requirements.txt
django111: Django>=1.11,<1.12
py3-django20: Django>=2.0,<2.1
py3-django21: Django>=2.1
commands =
pytest
But pip
does not support double requirements and will throw an error even though there is no conflict in how the version constraints are specified.
The drawback of using commands
to override the installation is that it needs to remove the django
package version installed via requirements.txt
to install the desired one. Is there a way to avoid that extra step?