Custom Loader Plugin #2882
-
I'm working on upgrading my plugin to the new tox4 method of doing things. I've cut version 1.x of the plugin to work with tox 3, so I'm ready to completely replace the hooks to the new way. My plugin has two features that it adds:
As I understand it, adding a few CLI options is still straightforward. I see several places in the current code where that happens and I believe I can update that code easily.
Does anyone else have a plugin that's compatible with tox 4.x which does something similar that I can see to use as a crib sheet? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I'm not aware of similar plugins but the advice from discord is the way to go 🙂 Here's a quick demonstration via an inline plugin seeded via
# toxfile.py
from tox.config.loader.memory import MemoryLoader
from tox.config.sets import CoreConfigSet, EnvConfigSet
from tox.config.types import EnvList
from tox.plugin import impl
from tox.session.state import State
@impl
def tox_add_core_config(core_conf: CoreConfigSet, state: State) -> None:
# override env list
core_conf.loaders.insert(0, MemoryLoader(env_list=EnvList(["a", "b"])))
# extend env list
env_list = cast(EnvList, core_conf["env_list"])
env_list.envs.extend(["a", "b"])
@impl
def tox_add_env_config(env_conf: EnvConfigSet, state: State) -> None:
env_conf.loaders.insert(0, MemoryLoader(description=f"env for {env_conf.name}")) # tox.ini
[tox]
env_list =
C ❯ tox l
default environments:
C -> env for C
a -> env for a
b -> env for b |
Beta Was this translation helpful? Give feedback.
I'm not aware of similar plugins but the advice from discord is the way to go 🙂 Here's a quick demonstration via an inline plugin seeded via
toxfile.py
.