From 30cdd31dc73204d44e1ad371c05b7892a4f0854b Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 20 Dec 2021 20:04:36 +0000 Subject: [PATCH] Use uuid4 to improve tempfile parallel creation --- setuptools/build_meta.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index 3c884eb775..bcfc1611ad 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -34,6 +34,7 @@ import tempfile import warnings from itertools import chain +from uuid import uuid4 import setuptools import distutils @@ -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: