From 8a7ee5a7d5844c60068f3436f2f327e61690551c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 9 Jul 2018 16:19:17 -0400 Subject: [PATCH] Add distclean to remove old build files Signed-off-by: Joffrey F --- script/release/release.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/script/release/release.py b/script/release/release.py index 9be06b211..b47c38875 100755 --- a/script/release/release.py +++ b/script/release/release.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import argparse import os +import shutil import sys import time from distutils.core import run_setup @@ -133,8 +134,37 @@ def print_final_instructions(args): ) +def distclean(): + print('Running distclean...') + dirs = [ + os.path.join(REPO_ROOT, 'build'), os.path.join(REPO_ROOT, 'dist'), + os.path.join(REPO_ROOT, 'docker-compose.egg-info') + ] + files = [] + for base, dirnames, fnames in os.walk(REPO_ROOT): + for fname in fnames: + path = os.path.normpath(os.path.join(base, fname)) + if fname.endswith('.pyc'): + files.append(path) + elif fname.startswith('.coverage.'): + files.append(path) + for dirname in dirnames: + path = os.path.normpath(os.path.join(base, dirname)) + if dirname == '__pycache__': + dirs.append(path) + elif dirname == '.coverage-binfiles': + dirs.append(path) + + for file in files: + os.unlink(file) + + for folder in dirs: + shutil.rmtree(folder, ignore_errors=True) + + def resume(args): try: + distclean() repository = Repository(REPO_ROOT, args.repo) br_name = branch_name(args.release) if not repository.branch_exists(br_name): @@ -186,6 +216,7 @@ def cancel(args): bintray_api = BintrayAPI(os.environ['BINTRAY_TOKEN'], args.bintray_user) print('Removing Bintray data repository for {}'.format(args.release)) bintray_api.delete_repository(args.bintray_org, branch_name(args.release)) + distclean() except ScriptError as e: print(e) return 1 @@ -194,6 +225,7 @@ def cancel(args): def start(args): + distclean() try: repository = Repository(REPO_ROOT, args.repo) create_initial_branch(repository, args) @@ -216,6 +248,7 @@ def start(args): def finalize(args): + distclean() try: repository = Repository(REPO_ROOT, args.repo) img_manager = ImageManager(args.release)