Expose a new tox_extend_envs hook in plugins API#3591
Merged
gaborbernat merged 4 commits intotox-dev:mainfrom Aug 29, 2025
Merged
Expose a new tox_extend_envs hook in plugins API#3591gaborbernat merged 4 commits intotox-dev:mainfrom
tox_extend_envs hook in plugins API#3591gaborbernat merged 4 commits intotox-dev:mainfrom
Conversation
This patch adds a new hook point in the tox lifecycle that lets plugin authors declare additional environment names dynamically. This can be used to provide extra tox environments shipped as installable plugins. Resolves tox-dev#3510.
gaborbernat
reviewed
Aug 29, 2025
Contributor
Author
|
Yep, that's why it's still a draft. I've been playing with a PoC in a |
for more information, see https://pre-commit.ci
webknjaz
added a commit
to webknjaz/tox
that referenced
this pull request
Aug 29, 2025
a774591 to
5c1c534
Compare
5c1c534 to
34b4342
Compare
Contributor
Author
|
cc @sirosen @jugmac00 — this is a new API that @gaborbernat and I hacked together at PyCon US in the spring. FYI. |
gaborbernat
approved these changes
Aug 29, 2025
Contributor
Author
|
@gaborbernat thanks for merging 🙏 Would you mind releasing so I could use this in a plugin, finally? |
Member
webknjaz
added a commit
to webknjaz/tox
that referenced
this pull request
Sep 1, 2025
This is a follow-up for tox-dev#3591 that makes it prominent in the docs when the hook was first added.
webknjaz
added a commit
to webknjaz/tox
that referenced
this pull request
Sep 2, 2025
Previously (PR tox-dev#3591) a new hook point was added. The tests checked that it works well with the `tox config` and `tox list` commands. However, `tox run` turned out to have a problem — it would complain that there's no such env, when invoked: ```console ROOT: 170 E HandledError| provided environments not found in configuration file: pip-compile-tox-env-lock [tox/run.py:23] ``` Turned out, this was because the config object is being interated twice in some subcommands. This in turn iterates over the discovered additional ephemeral environments list object. The implementation passes an iterator into it and so when it's first accessed, it's exhausted and the second attempt does not give the same envs, causing inconsistency. The patch solves this by using `itertools.tee()`, making sure that the underlying iterable is always cached and it's possible to repeat iteration as many times as possible without loosing the data in the process.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds a new hook point in the tox lifecycle that lets plugin authors declare additional environment names dynamically. This can be used to provide extra tox environments shipped as installable plugins.
Resolves #3510.
tox -e fix)docs/changelogfolder