Repository navigation
Commit ea2dedb
build(tox): let older tox provision one that reads
tox older than 4.21 does not read native TOML from `[tool.tox]`, so
with the configuration there, it cannot see `requires` and provision a
newer tox. It looks only at `legacy_tox_ini`, an INI string in
`[tool.tox]`, finds none, and assumes an empty configuration. Plain
`tox` then passes without testing anything: with tox 4.11.3, it
reported "assuming empty tox.ini", installed GitPython with `gitdb`
from PyPI into a default `py` environment that has no commands, and
exited with status 0. `tox -e ruff` failed with "provided environments
not found in configuration file".
Add a `legacy_tox_ini` for older tox. Whatever older tox reads, tox
4.21 to 4.40 also use instead of the native tables, because they
prefer `legacy_tox_ini` when both are present. Only tox 4.41 and later
prefer the native tables and ignore it. `tox.ini` and `setup.cfg` are
no alternative, since even current tox reads them first. So the one
stub has to work for every tox before 4.41. It has four parts:
- `requires = tox>=4.41`, so that each such tox installs and runs tox
4.41 or later. Raise the native `requires` to match, since only tox
4.41 and later read it now. A stub requiring only 4.22 was not
enough: tox 4.22.0, 4.23.2, 4.25.0, 4.30.0, and 4.40.0 found that
met, and saw an empty configuration.
- An `env_list` naming every environment, including `gix`. tox 4.11.3
and the later versions tried, though not 4.0.0 or 4.4.12, check the
names given to `-e` against the configuration they read, before
provisioning, so without this, `tox -e ruff` still failed with
"provided environments not found". The list must be kept in step
with the native tables. A missing name makes older tox reject that
environment, rather than run anything else.
- A `[testenv]` whose command always fails, saying that tox 4.41 or
later is needed. A tox that provisions never runs it. But if the
stub's `requires` were removed or lowered, older tox would run the
stub's environments instead: tox 4.40.0, given the stub without
`requires`, installed GitPython, ran nothing, and reported success.
- `[testenv:.tox]` with `base_python` listing Python 3.10 and later.
tox provisions into its `.tox` environment, by default with the
Python it runs on, and tox 4.41 needs Python 3.10. Without this, tox
4.30.0 running on Python 3.9 failed to install a newer tox
("ResolutionImpossible"). This list, too, must be kept in step with
the Python versions tested.
So a part that is missing or wrong makes older tox fail, not pass
without testing anything. The README now says what this needs: a
download, and Python 3.10 or later.
The stub is INI, the format tox's documentation calls deprecated,
because older tox reads nothing else. Comments on it say so, and that
it can be removed once tox older than 4.41 need not be supported.
Checked in copies of the project with `tox config -e gix -k
description` and `tox -e ruff`:
- With tox running on Homebrew's Python 3.13, tox 4.0.0, 4.5.0, 4.11.3,
4.15.0, 4.20.0, 4.21.0, 4.21.2, 4.22.0, 4.25.0, 4.30.0, 4.35.0, and
4.40.0 provisioned a newer tox, which showed the native description
of `gix` and passed `ruff`. tox 4.41.0, 4.50.0, 4.60.0, and 4.67.1
did the same without provisioning.
- With tox running on Python 3.9.6, tox 4.0.0, 4.11.3, 4.20.0, 4.21.0,
4.22.0, 4.25.0, and 4.30.0 did the same, with the newer tox on Python
3.13. So did all of those but 4.30.0 on Python 3.8.20, which that
version does not support.
- With tox 4.20.0 on Python 3.9, plain `tox --notest` provisioned a
newer tox, which set up exactly the environments in the native
`env_list`.
- With the stub's `requires` line removed, tox 4.40.0 on Python 3.13,
and tox 4.30.0 and 4.20.0 on Python 3.9, failed each environment with
the guard's message.
- tox 3.28.0 worked when running on Python 3.13, but failed on Python
3.9. tox 3 knows only `basepython`, not `base_python`, so it
provisions with the Python it runs on.
`tox list` fails after provisioning with tox 4.6.0 to 4.14.1, with
"AttributeError: 'Parsed' object has no attribute
'list_dependencies'" from inside those versions. tox 4.5.0 and 4.14.2
list the environments, and running environments works with all of
them.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>[tool.tox]
1 parent 1b69c99 commit ea2dedb
2 files changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
0 commit comments