Skip to content

Commit

Permalink
Merge pull request #1253 from maxbachmann/main
Browse files Browse the repository at this point in the history
avoid RecursionError on Windows
  • Loading branch information
joerick committed Sep 4, 2022
2 parents 0117165 + ed73b75 commit 2dfeb94
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cibuildwheel/__main__.py
Expand Up @@ -5,7 +5,6 @@
import shutil
import sys
import tarfile
import tempfile
import textwrap
from pathlib import Path
from tempfile import mkdtemp
Expand Down Expand Up @@ -130,8 +129,8 @@ def main() -> None:
return

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

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

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


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

0 comments on commit 2dfeb94

Please sign in to comment.