Skip to content

Use Nox for tasks needed controlled Python envs

Pierre Augier requested to merge topic/default/introduce-nox into branch/default

Building the doc and formatting Python files require requirements (docutils and black~=23.12.1). A good tool to ease such things is Nox. Here, I use it with a UV backend.

Mercurial developers only need to install Nox (typically with pipx) and optionally UV (with pipx or the UV installer) and the make targets will be run with the right tools and versions (black, docutils, build, ...).

Few words on Nox. It's a project similar to Tox but which uses a Python file for configuration (noxfile.py). It can be used for testing with controlled environments. However, here I use it only to run tasks needed Python requirements.

From my experience, it's very reliable and user friendly.

It's a pure Python tool and can be installed anywhere with pipx or UV.

Nox can use UV to create/update environments which makes it really fast enough.

In this MR, I use it only for 3 tasks. However, I guess it could be useful for more tasks (for example linting).

I'm going to improve the commit about formatting to

  • get the black version from pyproject.toml
  • use hgext/fix.py
Edited by Pierre Augier

Merge request reports

Loading