import argparse
import json
-import distutils.dir_util
import os.path
import subprocess
import sys
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.
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
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 = [
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)