diff options
author | Jack Lloyd <[email protected]> | 2015-12-31 15:39:08 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-31 15:39:08 -0500 |
commit | b42fc5375d5747e98930841a695302f625595dd7 (patch) | |
tree | 0f80e7c332a31a18e2feef9025f63e9560b84f43 /configure.py | |
parent | b269c8d1ce0cb5412712a8df963b2205364e17ae (diff) | |
parent | daadca1b242023c2efbc3536561af42250643912 (diff) |
Merge pull request #353 from neusdan/robust_build_setup_windows
make shutil.rmtree and os.makedirs more robust to AV interference
Diffstat (limited to 'configure.py')
-rwxr-xr-x | configure.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/configure.py b/configure.py index 0eb5eaa56..c76cad0aa 100755 --- a/configure.py +++ b/configure.py @@ -1950,16 +1950,43 @@ def main(argv = None): # Now begin the actual IO to setup the build + # Workaround for Windows systems where antivirus is enabled GH #353 + def robust_rmtree(path, max_retries=5): + for _ in range(max_retries): + try: + shutil.rmtree(path) + return + except OSError: + time.sleep(0.1) + + # Final attempt, pass any Exceptions up to caller. + shutil.rmtree(path) + + # Workaround for Windows systems where antivirus is enabled GH #353 + def robust_makedirs(directory, max_retries=5): + for _ in range(max_retries): + try: + os.makedirs(directory) + return + except OSError as e: + if e.errno == errno.EEXIST: + raise + else: + time.sleep(0.1) + + # Final attempt, pass any Exceptions up to caller. + os.makedirs(dir) + try: if options.clean_build_tree: - shutil.rmtree(build_config.build_dir) + robust_rmtree(build_config.build_dir) except OSError as e: if e.errno != errno.ENOENT: logging.error('Problem while removing build dir: %s' % (e)) for dir in build_config.build_dirs: try: - os.makedirs(dir) + robust_makedirs(dir) except OSError as e: if e.errno != errno.EEXIST: logging.error('Error while creating "%s": %s' % (dir, e)) |