-
-
Notifications
You must be signed in to change notification settings - Fork 539
Expose a new tox_extend_envs
hook in plugins API
#3591
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
Expose a new tox_extend_envs
hook in plugins API
#3591
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this if you add a tests demonstrating it.
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
a774591
to
5c1c534
Compare
5c1c534
to
34b4342
Compare
cc @sirosen @jugmac00 — this is a new API that @gaborbernat and I hacked together at PyCon US in the spring. FYI. |
@gaborbernat thanks for merging 🙏 Would you mind releasing so I could use this in a plugin, finally? |
This is a follow-up for tox-dev#3591 that makes it prominent in the docs when the hook was first added.
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.
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/changelog
folder