aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMike Schuchardt <mikes@lunarg.com>2021-04-28 12:10:06 -0700
committerMike Schuchardt <mikes@lunarg.com>2021-04-29 13:06:56 -0700
commit2a3bbb508520a620409e606a0c3e758a8987d5f6 (patch)
treedebf387d244aed0da6e207a2f84006c35ed27dab /scripts
parenteb3d67bd17ee433e2b0a8e56a7249bd83908812e (diff)
downloadusermoji-2a3bbb508520a620409e606a0c3e758a8987d5f6.tar.xz
scripts: Switch from mkpath to makedirs
distutils.dir_util.mkpath will not re-create a directory if it has been removed with shutil.rmtree because it caches the filesystem under the hood. This was causing the clone retry to fail on the second iteration every time. Switch to using os.makedirs for equivalent functionality without the cache.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/update_deps.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/update_deps.py b/scripts/update_deps.py
index ea21c9fb..ffd928f6 100755
--- a/scripts/update_deps.py
+++ b/scripts/update_deps.py
@@ -242,7 +242,6 @@ from __future__ import print_function
import argparse
import json
-import distutils.dir_util
import os.path
import subprocess
import sys
@@ -275,6 +274,12 @@ def on_rm_error( func, path, exc_info):
os.chmod( path, stat.S_IWRITE )
os.unlink( path )
+def make_or_exist_dirs(path):
+ "Wrapper for os.makedirs that tolerates the directory already existing"
+ # Could use os.makedirs(path, exist_ok=True) if we drop python2
+ if not os.path.isdir(path):
+ os.makedirs(path)
+
def command_output(cmd, directory, fail_ok=False):
"""Runs a command in a directory and returns its standard output stream.
@@ -346,7 +351,7 @@ class GoodRepo(object):
def Clone(self, retries=10, retry_seconds=60):
print('Cloning {n} into {d}'.format(n=self.name, d=self.repo_dir))
for retry in range(retries):
- distutils.dir_util.mkpath(self.repo_dir)
+ make_or_exist_dirs(self.repo_dir)
try:
command_output(['git', 'clone', self.url, '.'], self.repo_dir)
# If we get here, we didn't raise an error
@@ -426,7 +431,7 @@ class GoodRepo(object):
shutil.rmtree(self.install_dir)
# Create and change to build directory
- distutils.dir_util.mkpath(self.build_dir)
+ make_or_exist_dirs(self.build_dir)
os.chdir(self.build_dir)
cmake_cmd = [
@@ -665,7 +670,7 @@ def main():
save_cwd = os.getcwd()
# Create working "top" directory if needed
- distutils.dir_util.mkpath(args.dir)
+ make_or_exist_dirs(args.dir)
abs_top_dir = os.path.abspath(args.dir)
repos = GetGoodRepos(args)