Skip to content

Commit

Permalink
Don't use nox.session.create_tmp.
Browse files Browse the repository at this point in the history
It's basically a footgun, in that it:

    * doesn't create a pseudorandom temporary directory, it just gives you
      the path 'tmp/'
    * thereby then doesn't create separate directories if you call it multiple
      times
    * mutates the global (shell) environment state by setting TMPDIR to this
      'new' directory so other processes can now 'accidentally' end up
      sticking things in it

(In particular I was really confused how/why non-distribution files were being
plopped into my python -m build's outdir, but it was because TMPDIR was
sticking around)
  • Loading branch information
Julian committed Jul 9, 2023
1 parent 7046da1 commit 4817d36
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from tempfile import TemporaryDirectory
import os

import nox
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)")
Expand Down

0 comments on commit 4817d36

Please sign in to comment.