Skip to content

Commit

Permalink
Use uuid4 to improve tempfile creation in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Dec 20, 2021
1 parent 574cb20 commit 4a3487e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import tempfile
import warnings
from itertools import chain
from uuid import uuid4

import setuptools
import distutils
Expand Down Expand Up @@ -100,9 +101,9 @@ def _patch_distutils_exec():

def _exec(code, global_vars):
try:
_, tmp = tempfile.mkstemp(suffix="setup.py")
with open(tmp, "wb") as f:
f.write(code)
f, tmp = tempfile.mkstemp(suffix=f"{uuid4()}-setup.py", text=False)
f.write(code)
f.close() # Needed to re-open with tokenize
with tokenize.open(tmp) as f:
code = f.read().replace(r'\r\n', r'\n')
finally:
Expand Down

0 comments on commit 4a3487e

Please sign in to comment.