I'm using tox for my project and I would like to install IPython as an optional requirement that is used only during development.
I'm using a setup.cfg
file and I have defined the following testenv (simplified):
[options]
extras_require =
localdev = ipython
[tox:tox]
env_list = py311
[testenv:py311]
deps = <bunch of deps here>
extras = ipython
The testenv works perfectly, but I can't get the optional IPython install to work.
I have tried variations of the following:
$ tox -e 'py311[ipython]' # the quotes are needed to escape square brackets
$ tox -e 'py311[localdev]'
$ tox -e py311 -e localdev
$ tox -e py311 -e '.[localdev]'
Everything fails with a similar error:
...
ValueError: py311[localdev]
py311[localdev]: FAIL code 2 (0.00 seconds)
evaluation failed :( (0.05 seconds)
I have found this answer: Install optional dependencies with tox but sadly I'm missing something and I can't get it to work.
I know that I don't know how everything works so no need to point that out ;)
Your help is much appreciated!
extras
is the keyword in tox.ini
you need to use to install optional dependencies automatically.
So you need to have a section like
[testenv:py311]
deps = <bunch of deps here>
extras = localdev
And then just run tox -e py311
.
Disclaimer: I am one of the tox maintainers.