Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install optional dependencies with tox

Tags:

python

tox

I use tox to test a python project with the following basic config (tox.ini):

[tox]
envlist = py3
isolated_build = True

[testenv]
deps =
    pytest
    pytest-cov
commands =
    pytest --cov {envsitepackagesdir}/foobar --cov-report xml --cov-report term

Unfortunately, the package's optional dependencies (as specified in setup.cfg) don't get installed; the corresponding line in raw pip would be

pip install .[all]

How to make tox install all optional dependencies?

like image 456
Nico Schlömer Avatar asked May 15 '26 09:05

Nico Schlömer


1 Answers

The supported way to do this is to use the extras key in your testenv

for example:

[testenv]
deps = -rrequirements-dev.txt
extras = typed

this will install .[typed] or -e .[typed] if usedevelop = true


disclaimer: I'm one of the tox maintainers

like image 57
Anthony Sottile Avatar answered May 17 '26 22:05

Anthony Sottile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!