meta icon indicating copy to clipboard operation
meta copied to clipboard

Document centrally about tox/nox

Open chrisjsewell opened this issue 5 years ago • 3 comments

I was going to bring this up in meta, since I've started adding tox.ini to repositories (see markdown-it-py and myst-parser). Basically tox/nox are very helpful when switching between different repos/projects, to quickly run the tests and doc builds against multiple environments

The "normal" workflow for me before was to open up a repository's folder in VS Code, create a conda environment, install the package into it, then run pytest, make html, etc

With https://tox.readthedocs.io it doesn't preclude you from doing this, but offers an easier/quicker approach; you just have tox installed in your base environment (and optionally tox-conda when using conda). Then, when you open a new repo folder all you have to do is run tox. Depending on your tox.ini and what python versions you have available, this will then create one or more virtual environments in a local .tox folder, then run the tests using each environment. For example, with the myst-parser tox.ini it runs: py36-sphinx2,py37-sphinx2,py38-sphinx2,py36-sphinx3,py37-sphinx3,py38-sphinx3,docs, by default, or you can run a single one with e.g. tox -e py38-sphinx3

To parse additional arguments to pytest, you just put them after a -- (assuming this is setup in the tox.ini) e.g. tox -e py38-sphinx3 -- -x path/to/test.py

nox is less mature/widely used than tox, but builds on tox, by offering a more configurable execution process, due to using a "dynamic" python configuration file (nox.py) instead of a "static" file (tox.ini). This is needed here for running the live server.

Hmm, what does removing the nox folder do?

So getting back to your original question. If you delete the .tox/.nox folder you simply delete any previously built environments and tox/nox will rebuild them when called (you can also force a rebuild with tox -r.

Originally posted by @chrisjsewell in https://github.com/executablebooks/sphinx-book-theme/issues/187#issuecomment-675771890

chrisjsewell avatar Aug 19 '20 04:08 chrisjsewell

I was just wondering what the tox.ini did :-) -- this is great. Thanks.

mmcky avatar Aug 20 '20 01:08 mmcky

We can add it in the new tips and tricks section 😄

chrisjsewell avatar Aug 20 '20 01:08 chrisjsewell

Nice Idea!

mmcky avatar Aug 20 '20 01:08 mmcky