Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify more than one dependency in scoped "deps" config section #2506

Open
robblovell opened this issue Sep 27, 2022 · 1 comment
Labels
feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@robblovell
Copy link

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.

@jugmac00
Copy link
Member

jugmac00 commented Oct 1, 2022

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?

@gaborbernat gaborbernat added the help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

3 participants