tox
tox copied to clipboard
Ability to specify more than one dependency in scoped "deps" config section
In a project, to run the mypy static analyzer, I need to install both mypy and types-requests. While I could specify a separate requirements.txt for this, I would rather just put it as a list in the deps section:
[tox]
envlist =
tests
dev
lint
compile
skipsdist = true
allowlist_externals =
tox-echo.sh
[testenv]
deps =
dev: -r media_analysis/requirements-m1.txt
tests: -r media_analysis/requirements-m1.txt
lint: pyflakes
compile: mypy, types-requests
commands =
dev: ./tox-echo.sh
tests: python -m pytest media_analysis/
lint: pyflakes media_analysis/
compile: dmypy run --timeout 5 -- media_analysis
tox -e compile
yields an error with installing of the dependencies mypy
and types-requests
:
ERROR: invocation failed (exit code 1), logfile: .../.tox/compile/log/compile-1.log
=================================================================================================== log start ====================================================================================================
ERROR: Invalid requirement: 'mypy, types-requests'
==================================================================================================== log end =====================================================================================================
ERROR: could not install deps [mypy, types-requests];
v = InvocationError(".../.tox/compile/bin/python -m pip install 'mypy, types-requests'", 1)
____________________________________________________________________________________________________ summary _____________________________________________________________________________________________________
ERROR: compile: could not install deps [mypy, types-requests];
v = InvocationError(".../.tox/compile/bin/python -m pip install 'mypy, types-requests'", 1)
It appears the arguments are not split at the comma and passed as a full string to pip.
python -m pip install 'mypy, types-requests'
instead of
python -m pip install 'mypy' 'types-requests'
Note that specifying compile: mypy, types-requests
with a space (compile: mypy types-requests
) instead makes no difference. compile: mypy types-requests
would also be more consistent with the way pip works and might be the right implementation if this feature is included.
My workaround is to use a separate requirements.txt or to specify the extra dependency before the scoped ones:
...
[testenv]
deps =
types-requests
dev: -r media_analysis/requirements-m1.txt
tests: -r media_analysis/requirements-m1.txt
lint: pyflakes
compile: mypy
...
or
...
[testenv]
deps =
dev: -r media_analysis/requirements-m1.txt
tests: -r media_analysis/requirements-m1.txt
lint: pyflakes
compile: -r media_analysis/requirements-compile.txt
...
I think the dependencies should be parsed and split at the comma so that multiple dependencies can be specified.
The usual way to define these kind of environments would be...
[testenv]
deps =
dev: -r media_analysis/requirements-m1.txt
tests: -r media_analysis/requirements-m1.txt
lint: pyflakes
compile: mypy, types-requests
commands =
dev: ./tox-echo.sh
tests: python -m pytest media_analysis/
lint: pyflakes media_analysis/
compile: dmypy run --timeout 5 -- media_analysis
[testenv:dev]
deps = -r media_analysis/requirements-m1.txt
commands = ./tox-echo.sh
[testenv:tests]
deps = -r media_analysis/requirements-m1.txt
commands = python -m pytest media_analysis/
...
Any reason why you do not follow this common pattern?