Merge pull request #1253 from maxbachmann/main

avoid RecursionError on Windows
This commit is contained in:
Joe Rickerby
2022-09-04 15:00:08 +01:00
committed by GitHub
+10 -3
View File
@@ -5,7 +5,6 @@ import os
import shutil import shutil
import sys import sys
import tarfile import tarfile
import tempfile
import textwrap import textwrap
from pathlib import Path from pathlib import Path
from tempfile import mkdtemp from tempfile import mkdtemp
@@ -130,8 +129,8 @@ def main() -> None:
return return
# Tarfile builds require extraction and changing the directory # Tarfile builds require extraction and changing the directory
with tempfile.TemporaryDirectory(prefix="cibw-sdist-") as temp_dir_str: temp_dir = Path(mkdtemp(prefix="cibw-sdist-")).resolve(strict=True)
temp_dir = Path(temp_dir_str) try:
with tarfile.open(args.package_dir) as tar: with tarfile.open(args.package_dir) as tar:
tar.extractall(path=temp_dir) tar.extractall(path=temp_dir)
@@ -146,6 +145,12 @@ def main() -> None:
with chdir(temp_dir): with chdir(temp_dir):
build_in_directory(args) 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: def build_in_directory(args: CommandLineArguments) -> None:
@@ -253,6 +258,8 @@ def build_in_directory(args: CommandLineArguments) -> None:
else: else:
assert_never(platform) assert_never(platform)
finally: finally:
# avoid https://github.com/python/cpython/issues/86962 by performing
# cleanup manually
shutil.rmtree(tmp_path, ignore_errors=sys.platform.startswith("win")) shutil.rmtree(tmp_path, ignore_errors=sys.platform.startswith("win"))
if tmp_path.exists(): if tmp_path.exists():
log.warning(f"Can't delete temporary folder '{str(tmp_path)}'") log.warning(f"Can't delete temporary folder '{str(tmp_path)}'")