✨ feat(runner): add PEP 723 inline script metadata support#3912
Merged
gaborbernat merged 2 commits intotox-dev:mainfrom Mar 30, 2026
Merged
✨ feat(runner): add PEP 723 inline script metadata support#3912gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat merged 2 commits intotox-dev:mainfrom
Conversation
2e5e848 to
dd01130
Compare
rahuldevikar
approved these changes
Mar 30, 2026
04815cc to
42e4de4
Compare
PEP 723 lets scripts declare dependencies and Python version inline. The new virtualenv-pep-723 runner reads this metadata so environments need only a runner and script key — no deps/base_python duplication. The shared logic lives in Pep723Mixin (tox.tox_env.python.pep723) so third-party plugins like tox-uv can compose it with their own venv backend without duplicating code. The concrete runner composes the mixin with VirtualEnv and RunToxEnv, skipping PythonRun entirely so config keys like deps/extras/pylock are structurally absent. Closes tox-dev#3897
for more information, see https://pre-commit.ci
Contributor
tox-uv will also need an update to use it there? |
Member
Author
|
Yes. |
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.
Closes #3897.
PEP 723 lets Python scripts declare their dependencies and required Python version inline via comment blocks. Currently tox users must duplicate this information in their tox config, which drifts out of sync and defeats the purpose of the standard. The new
virtualenv-pep-723runner reads metadata directly from the script file, so a tox environment needs only arunnerandscriptkey.The shared PEP 723 logic lives in
Pep723Mixinattox.tox_env.python.pep723, independent of any venv backend. The concretePep723Runnercomposes the mixin withVirtualEnvandRunToxEnv, skippingPythonRunentirely so config keys likedeps,extras,dependency_groups, andpylockare structurally absent rather than registered and rejected. Packaging is unconditionally disabled via_register_package_confreturningFalse. Settingbase_pythonexplicitly is rejected to prevent conflicts with the script'srequires-pythonspecifier.The mixin design means tox-uv can add PEP 723 support by composing
Pep723MixinwithUvVenvandRunToxEnv— zero code duplication.