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 18, 2023
1 parent beda0e5 commit c22c205
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 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 @@ -36,17 +37,10 @@ def audit(session):

@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", "twine")
tmpdir = session.create_tmp()
session.run("python", "-m", "build", ROOT, "--outdir", tmpdir)
session.run("python", "-m", "twine", "check", "--strict", tmpdir + "/*")
with TemporaryDirectory() as tmpdir:
session.run("python", "-m", "build", ROOT, "--outdir", tmpdir)
session.run("twine", "check", "--strict", tmpdir + "/*")


@session(tags=["style"])
Expand Down Expand Up @@ -77,20 +71,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 c22c205

Please sign in to comment.