Skip to content

Commit

Permalink
Use uuid4 to improve tempfile parallel creation
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Dec 20, 2021
1 parent 574cb20 commit 30cdd31
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 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,7 +101,8 @@ def _patch_distutils_exec():

def _exec(code, global_vars):
try:
_, tmp = tempfile.mkstemp(suffix="setup.py")
fid, tmp = tempfile.mkstemp(suffix=f"{uuid4()}-setup.py", text=False)
os.close(fid) # Ignore the low level API
with open(tmp, "wb") as f:
f.write(code)
with tokenize.open(tmp) as f:
Expand Down

0 comments on commit 30cdd31

Please sign in to comment.