How to update tox environments when setup.cfg files change?

Viewed 28

How can I get tox to automatically recreate its virtualenvs with the new dependencies whenever I make a change to my package's setup.cfg file?

Normally a Python package would list its dependencies using the setuptools install_requires setting in its setup.cfg:

[options]
install_requires =
    google-auth-oauthlib
    PyJWT
    pyramid>=2.0.0

Then if using tox you'd list your test dependencies using the deps setting in tox.ini:

[testenv]
deps =
    pytest
    pytest-cov >= 3.5

If you make a change to the deps in tox.ini then the next time you run tox it'll notice the change and will recreate the virtualenv installing the new deps.

But if you make a change to the dependencies in the setup.cfg file tox will not notice this and won't recreate the virtualenv. You have to manually run tox --recreate to force recreation. Is there any way to get tox to automatically recreate the virtualenv when setup.cfg changes?

1 Answers

tox-recreate is a simple tox plugin that watches for changes to your setup.cfg file. Whenever you run a tox command it'll trigger tox to recreate the virtualenv if your setup.cfg has changed. To use it just add tox-recreate to the requires setting in your tox.ini file:

[tox]
requires = tox-recreate
Related