Tox 'HandledError| SetupCfg .. tox:tox not found' in projects with setup.cfg and pyproject.toml
Issue
Tox should run when an environment is specified tox -e lint in a project with a setup.cfg file for the [metadata] and all [tool.tox] configuration in pyproject.toml. But instead it gives an error about the section tox:tox not being found in setup.cfg.
Environment
Provide at least:
- OS: Arch Linux
- Python: 3.13.7
- Tox: 4.30.1
Output of pip list of the host Python, where tox is installed
Package Version
--------------------- --------------
arrow 1.3.0
binaryornot 0.4.4
cachetools 6.1.0
certifi 2025.8.3
cfgv 3.4.0
chardet 5.2.0
charset-normalizer 3.4.3
click 8.2.1
colorama 0.4.6
cookiecutter 2.6.0
cruft 2.16.0
distlib 0.3.9
filelock 3.18.0
gitdb 4.0.12
GitPython 3.1.45
identify 2.6.12
idna 3.10
Jinja2 3.1.6
markdown-it-py 4.0.0
MarkupSafe 3.0.2
mdurl 0.1.2
nodeenv 1.9.1
packaging 25.0
pip 25.2
platformdirs 4.3.8
pluggy 1.6.0
pre_commit 4.2.0
Pygments 2.19.2
pyproject-api 1.9.1
python-dateutil 2.9.0.post0
python-slugify 8.0.4
PyYAML 6.0.2
requests 2.32.5
rich 14.1.0
shellingham 1.5.4
six 1.17.0
smmap 5.0.2
text-unidecode 1.3
tox 4.30.1
typer 0.16.1
types-python-dateutil 2.9.0.20250809
typing_extensions 4.14.1
urllib3 2.5.0
virtualenv 20.31.2
Output of running tox
Output of tox -rvv
ROOT: HandledError| SetupCfg failed loading /home/lukken/projects/astron/lofar2/stingray/setup.cfg due to section tox:tox not found
Minimal example
setup.cfg
[metadata]
name = lofar-stingray
description = LOFAR station statistics gather and dump utility, writes station statistics continuously to the local S3 based object storage.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://git.astron.nl/lofar2.0/stingray
license = Apache License 2.0
classifiers =
Development Status :: 3 - Alpha
Environment :: No Input/Output (Daemon)
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Utilities
Topic :: System :: Archiving :: Compression
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Astronomy
[options]
include_package_data = true
packages = find:
python_requires = >=3.11
install_requires = file: requirements.txt
pyproject.toml
[build-system]
requires = [
"setuptools>=70.0",
"setuptools_scm[toml]>=8.0",
"wheel"
]
build-backend = "setuptools.build_meta"
[tool.tox]
# Generative environment list to test all supported Python versions
requires = ["tox>=4.21"]
env_list = ["lint"]
[tool.tox.env_run_base]
package = "editable"
deps = [
"-r{toxinidir}/requirements.txt",
"-r{toxinidir}/tests/requirements.txt"]
commands = [["python", "--version"], ["python", "-m", "pytest", "tests/{posargs}"]]
# Command prefixes to reuse the same virtualenv for all linting jobs.
[tool.tox.env.lint]
deps = [
"ruff",
"-r{toxinidir}/tests/requirements.txt"]
commands = [
["python", "-m", "ruff", "--version"],
]
I believe this regression was caused by #3578
cc @ssbarnea
@Dantali0n a bit unrelated, but you shouldn't have wheel in your [build-system].
Can confirm, just stumbled over same issue. "tox<4.30" helps (I also switched from the legacy hack to a native pyproject.toml tox config).
https://github.com/nsupdate-info/nsupdate.info/actions/runs/17476454410/job/49637437038?pr=586
@Daverball PRs are welcomed, tbh I ditched setup.cfg years ago and these days I am also dropping the tox.ini file from last projects.
Similarly, a project that has no tox configuration at all previously said No tox.ini or setup.cfg or pyproject.toml or tox.toml found, assuming empty tox.ini but continued successfully. With a valid setup.cfg file without a tox config, it now fails with the same error as reported here.
Maybe it would be enough (at least as a short term solution) to prefer pyproject.toml over setup.cfg, e.g. by moving SetupCfg a bit below in https://github.com/tox-dev/tox/blob/main/src/tox/config/source/discover.py
Tox (v4.32.0) similarly fails if you use tox.toml but also have a setup.cfg without tox:tox.
@cpburnz it's normally useful to contribute a regression test with your expectations in a PR. So if somebody starts working on fixing it, there would be something to check against.
I can provide a reproducible example. I don't know where to start with a regression test.
-------- Original Message -------- On Saturday, 11/15/25 at 06:30 πΊπ¦ Sviatoslav Sydorenko @.***> wrote:
webknjaz left a comment (tox-dev/tox#3602)
@.***(https://github.com/cpburnz) it's normally useful to contribute a regression test with your expectations in a PR. So if somebody starts working on fixing it, there would be something to check against.
β Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
A workaround is to use tox -c pyproject.toml explicitly.