Description
Over the course of having discoveries related to #3507, I realized that all the examples with injecting MemoryLoader(env_list=env_list)
add envs as default.
And so typing in tox
would attempt running them:
$ tox l
default environments:
pip-compile -> [tox-lock] Invoke pip-compile of pip-tools
pip-compile-build-lock -> [tox-lock] Produce a PEP 517/660 build deps lock
pip-compile-tox-env-lock -> [tox-lock] Produce a lock file for the passed tox env using current python
additional environments:
build-dists -> Build dists and put them into the dist/ folder
pre-commit -> Run the quality checks under python3; run as `SKIP=check-id1,check-id2 tox r -e pre-commit` to instruct the underlying `pre-commit` invocation avoid running said checks; Use `tox r -e pre-commit -- check-id1 --all-files` to select checks matching IDs aliases: `tox r -e pre-commit -- mypy --all-files` will run 3 MyPy invocations, but `tox r -e pre-commit -- mypy-py313 --all-files` runs one.
build-docs -> Build The Docs
I don't want to influence whatever the end-user configures as env_list
in their config, only providing additional envs that should be requested via tox r -e <env>
(or through the env var, or config explicitly).
It seems to me like a gap in the plugin API. Having stared long enough at the source code, it seems that the discovery of additional envs is tightly coupled with the source objects. It's effectively happening @
tox/src/tox/session/env_select.py
Line 180 in a985171
And if we unwrap a few layers of indirection, that effectively does
state.conf._src._discover_tox_envs(state.conf.core)
.
It looks like this currently means that adding a memory loader into the core config adds default envs that are processed separately when discovering all envs:
tox/src/tox/session/env_select.py
Line 172 in a985171
But adding “inactive” / “additional” envs would only be possible by monkey-patching the private
state.conf._src
object or state.conf.__iter__()
.
@gaborbernat should the plugin API just implement a tox_discover_envs()
hook or a method on the state
or config
objects for declaring additional environments?