pythontoxpyproject.toml

Tox doesn't find pyproject.toml?


It seems that I cannot manage tox to see my pyproject.toml. I've created a minimal example:

$ mkdir test
$ cd test
$ cat <<EOF > pyproject.toml
[build-system]
requires = ["cython", "setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.tox]
envlist = "py310"

[tool.tox.testenv]
deps = ["pytest"]
commands = ["pytest"]
EOF
$ ls
 ls
pyproject.toml
$ tox
ROOT: No tox.ini or setup.cfg or pyproject.toml found, assuming empty tox.ini at /home/user/testtox
...
$ tox --version
ROOT: No tox.ini or setup.cfg or pyproject.toml found, assuming empty tox.ini at /home/ycr/testtox
4.14.1 from /home/user/.local/lib/python3.10/site-packages/tox/__init__.py

Note that if I touch tox.ini it finds it :(

What's wrong?


Solution

  • The syntax for tox-related section in pyproject.toml is very strange:

    [build-system]
    requires = ["cython", "setuptools", "wheel"]
    build-backend = "setuptools.build_meta"
    
    [tool.tox]
    legacy_tox_ini = """
    [tox]
    envlist = py310
    
    [testenv]
    deps = pytest
    commands = pytest
    """
    

    See the docs.

    PS. In my not so humble opinion it would be better and nicer to move this to tox.ini.