-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tox4] Document loaders on config set #2287
Comments
Can you post an example code doing this? |
It has been a few weeks since I touched it last time but this should be it: @impl
def tox_add_env_config(env_conf, config):
loader = MemoryLoader(allowlist_externals=["*"])
env_name = next(config.env_list())
config.get_env(env_name, loaders=[loader]) To accomplish the same, I have my own executor where I can simply rewrite the option in the request: class CurrentEnvRunExecutor(Execute):
def build_instance(
self,
request,
options,
out,
err,
):
# Disable check for the external commands,
# all of them are external for us.
request.allow = None
return LocalSubProcessExecuteInstance(request, options, out, err) |
At that point, the config is already constructed. You're trying to construct it again that's causing the infinite recursion. If you want to extend the loaders can't you directly insert the memory loader into env_conf? |
https://github.com/tox-dev/tox/blob/rewrite/src/tox/config/sets.py#L27. e.g. https://github.com/tox-dev/tox-gh/blob/main/src/tox_gh/plugin.py#L63 Seems https://tox.wiki/en/rewrite/plugins_api.html#tox.config.sets.ConfigSet doesn't document the loader property, we really should. |
Thanks for your help, this little piece of code solved my problem: @impl
def tox_add_env_config(env_conf, config):
# This allows all external commands.
# All of them are extenal for us.
loader = MemoryLoader(allowlist_externals=["*"])
config.core.loaders.insert(0, loader) I see that you want to use this issue for better documentation of loaders so I'm gonna keep it open. |
I'm trying to port our tox extension to the new tox 4 and I have one problem described in this thread: fedora-python/tox-current-env#42 (review)
The problem basically is that it's not possible to call
get_env
intox_add_env_config
because it causes an endless recursion. I need to do it so I can overwrite some settings loaded from config with values from the extension.The text was updated successfully, but these errors were encountered: