Skip to content

Commit ed73b75

Browse files
committed
avoid RecursionError on Windows
1 parent 0117165 commit ed73b75

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cibuildwheel/__main__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import shutil
66
import sys
77
import tarfile
8-
import tempfile
98
import textwrap
109
from pathlib import Path
1110
from tempfile import mkdtemp
@@ -130,8 +129,8 @@ def main() -> None:
130129
return
131130

132131
# Tarfile builds require extraction and changing the directory
133-
with tempfile.TemporaryDirectory(prefix="cibw-sdist-") as temp_dir_str:
134-
temp_dir = Path(temp_dir_str)
132+
temp_dir = Path(mkdtemp(prefix="cibw-sdist-")).resolve(strict=True)
133+
try:
135134
with tarfile.open(args.package_dir) as tar:
136135
tar.extractall(path=temp_dir)
137136

@@ -146,6 +145,12 @@ def main() -> None:
146145

147146
with chdir(temp_dir):
148147
build_in_directory(args)
148+
finally:
149+
# avoid https://github.com/python/cpython/issues/86962 by performing
150+
# cleanup manually
151+
shutil.rmtree(temp_dir, ignore_errors=sys.platform.startswith("win"))
152+
if temp_dir.exists():
153+
log.warning(f"Can't delete temporary folder '{str(temp_dir)}'")
149154

150155

151156
def build_in_directory(args: CommandLineArguments) -> None:
@@ -253,6 +258,8 @@ def build_in_directory(args: CommandLineArguments) -> None:
253258
else:
254259
assert_never(platform)
255260
finally:
261+
# avoid https://github.com/python/cpython/issues/86962 by performing
262+
# cleanup manually
256263
shutil.rmtree(tmp_path, ignore_errors=sys.platform.startswith("win"))
257264
if tmp_path.exists():
258265
log.warning(f"Can't delete temporary folder '{str(tmp_path)}'")

0 commit comments

Comments
 (0)