Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
clean.py77 linesDownload Raw Back to command
1"""distutils.command.clean2 3Implements the Distutils 'clean' command."""4 5# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-186 7import os8from distutils._log import log9 10from ..core import Command11from ..dir_util import remove_tree12 13 14class clean(Command):15    description = "clean up temporary files from 'build' command"16    user_options = [17        ('build-base=', 'b', "base build directory (default: 'build.build-base')"),18        (19            'build-lib=',20            None,21            "build directory for all modules (default: 'build.build-lib')",22        ),23        ('build-temp=', 't', "temporary build directory (default: 'build.build-temp')"),24        (25            'build-scripts=',26            None,27            "build directory for scripts (default: 'build.build-scripts')",28        ),29        ('bdist-base=', None, "temporary directory for built distributions"),30        ('all', 'a', "remove all build output, not just temporary by-products"),31    ]32 33    boolean_options = ['all']34 35    def initialize_options(self):36        self.build_base = None37        self.build_lib = None38        self.build_temp = None39        self.build_scripts = None40        self.bdist_base = None41        self.all = None42 43    def finalize_options(self):44        self.set_undefined_options(45            'build',46            ('build_base', 'build_base'),47            ('build_lib', 'build_lib'),48            ('build_scripts', 'build_scripts'),49            ('build_temp', 'build_temp'),50        )51        self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))52 53    def run(self):54        # remove the build/temp.<plat> directory (unless it's already55        # gone)56        if os.path.exists(self.build_temp):57            remove_tree(self.build_temp, dry_run=self.dry_run)58        else:59            log.debug("'%s' does not exist -- can't clean it", self.build_temp)60 61        if self.all:62            # remove build directories63            for directory in (self.build_lib, self.bdist_base, self.build_scripts):64                if os.path.exists(directory):65                    remove_tree(directory, dry_run=self.dry_run)66                else:67                    log.warning("'%s' does not exist -- can't clean it", directory)68 69        # just for the heck of it, try to remove the base build directory:70        # we might have emptied it right now, but if not we don't care71        if not self.dry_run:72            try:73                os.rmdir(self.build_base)74                log.info("removing '%s'", self.build_base)75            except OSError:76                pass77 
codekingpro/portable-devtools · Team Ai