-
-
Notifications
You must be signed in to change notification settings - Fork 168
Description
How would this feature be useful?
Currently, Nox builds and installs a fresh wheel for every session. That is slow & unnecessary for 99.999% of situations.
Describe the solution you'd like
I'd like something akin to tox's
[testenv]
package = wheel
wheel_build_env = .pkg
(see also https://hynek.me/articles/turbo-charge-tox/)
so I can say that one wheel is plenty for all environments, like
nox.options.one_wheel_for_all = True
I don't think Nox needs as fine-grained controls like tox has – courtesy of Python. But this one use case is common enough to save a lot of CPU and IO cycles.
Describe alternatives you've considered
You can do it by hand, either by passing an argument:
@nox.session
def tests(session):
posargs = list(session.posargs)
try:
i = posargs.index("--installpkg")
pkg = posargs[i + 1]
del posargs[i : i + 2]
except ValueError:
pkg = "."
session.install(pkg)
Or an explicit environment:
@nox.session
def build(session: nox.Session) -> None:
shutil.rmtree("dist", ignore_errors=True)
session.install("build")
session.run("python", "-m", "build")
@nox.session(python=[...])
def tests(session: nox.Session) -> None:
(wheel,) = Path("dist").glob("*.whl")
session.install(wheel, "coverage[toml]")
session.run("coverage", "run", "-m", "pytest", *session.posargs)
if os.environ.get("CI") != "true":
session.notify("coverage_report")
But but both require manual intervention and present sharp edges. E.g. calling nox -s tests -p 3.11
won't rebuild the package and will run the tests against outdated code.
If this would be handled by Nox, I would expect it to make sure the wheel is built when I call session.install('.')
Anything else?
No response