feat: support PEP 723 noxfiles #881
Draft
+199
−8
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.
I've started #848. This allows you to write a noxfile like this:
Any dependencies, including version ranges and nox, will be checked. If not satisfied, nox will make a new
.nox/_nox_script_mode
environment, set it up with the above dependencies, and then pass control to the new nox environment. Requires-python is not respected yet, might need #814.I've allowed this to be passed via flag and envvar, but envvar always comes first, and overrides the flag. This ensures the second run will never trigger a third run of nox. If someone has other ideas for ways to ensure this, I'm open. Also, the envvar is needed if you request an older nox, since the flag won't be valid in the "inner" run.
--script-mode=fresh
allows you to enforce a fresh environment.It supports both pip and uv; since this is a new feature, defaulted to uv if available, and fallback on pip. Maybe should be configurable.
I also need to check Windows, pipx doesn't use process replacement there; the original PR said it "wasn't reliable" for pipx. Not sure about us. pypa/pipx#531 The Python docs seem to indicate it's not as fancy there, but it seems like it should work. Edit: it doesn't. :)
Fix #414.