diff --git a/noxfile.py b/noxfile.py index 1c257171..9993dcbb 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ from pathlib import Path +from tempfile import TemporaryDirectory import os import nox @@ -106,18 +107,11 @@ def audit(session, installable): @session(tags=["build"]) def build(session): - session.install("build") - tmpdir = session.create_tmp() - session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) - - -@session(tags=["style"]) -def readme(session): session.install("build", "docutils", "twine") - tmpdir = session.create_tmp() - session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) - session.run("python", "-m", "twine", "check", "--strict", tmpdir + "/*") - session.run("rst2html5.py", "--halt=warning", CHANGELOG, "/dev/null") + with TemporaryDirectory() as tmpdir: + session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) + session.run("twine", "check", "--strict", tmpdir + "/*") + session.run("rst2html5.py", "--halt=warning", CHANGELOG, "/dev/null") @session() @@ -154,20 +148,21 @@ def typing(session): ) def docs(session, builder): session.install("-r", DOCS / "requirements.txt") - tmpdir = Path(session.create_tmp()) - argv = ["-n", "-T", "-W"] - if builder != "spelling": - argv += ["-q"] - session.run( - "python", - "-m", - "sphinx", - "-b", - builder, - DOCS, - tmpdir / builder, - *argv, - ) + with TemporaryDirectory() as tmpdir_str: + tmpdir = Path(tmpdir_str) + argv = ["-n", "-T", "-W"] + if builder != "spelling": + argv += ["-q"] + session.run( + "python", + "-m", + "sphinx", + "-b", + builder, + DOCS, + tmpdir / builder, + *argv, + ) @session(tags=["docs", "style"], name="docs(style)")