Пример #1
0
    def run(self):
        # call base class clean
        clean.run(self)

        # clean auto-generated files
        paths = [os.path.join(here, "webgnome_api")]
        file_patterns = ["*.pyc"]

        for path in paths:
            for pattern in file_patterns:
                file_list = [
                    os.path.join(dirpath, f)
                    for dirpath, dirnames, files in os.walk(path)
                    for f in fnmatch.filter(files, pattern)
                ]

                for f in file_list:
                    try:
                        os.remove(f)
                        print "Deleted auto-generated file: {0}".format(f)
                    except OSError as err:
                        print ("Failed to remove {0}. Error: {1}".format(f, err))

        rm_dir = ["webgnome_api.egg-info"]
        for dir_ in rm_dir:
            try:
                shutil.rmtree(dir_)
                print "Deleted auto-generated directory: {0}".format(dir_)
            except OSError as err:
                if err.errno != 2:
                    # we report everything except file not found.
                    print ("Failed to remove {0}. Error: {1}".format(dir_, err))
Пример #2
0
    def run(self):
        # In addition to what the normal clean run does, remove pyc
        # and pyo and backup files from the source tree.
        distutils_clean.run(self)

        def should_remove(filename):
            if (filename.lower()[-4:] in [".pyc", ".pyo"] or
                    filename.endswith("~") or
                    (filename.startswith("#") and filename.endswith("#"))):
                return True
            else:
                return False
        for pathname, dirs, files in os.walk(os.path.dirname(__file__)):
            for filename in (f for f in files if should_remove(f)):
                try:
                    os.unlink(os.path.join(pathname, filename))
                except EnvironmentError as err:
                    print(str(err))

        try:
            os.unlink("MANIFEST")
        except OSError:
            pass

        for base in ["coverage", "build", "dist"]:
            path = os.path.join(os.path.dirname(__file__), base)
            if os.path.isdir(path):
                shutil.rmtree(path)
Пример #3
0
    def run(self):
        _clean.run(self)

        # Remove egg-info directory
        if self.all:
            dirs = self.distribution.package_dir
            egg_basedir = (dirs or {}).get('', os.curdir)

            for egg_infodir in fnfilter(os.listdir(egg_basedir), '*.egg-info'):
                if os.path.exists(egg_infodir):
                    remove_tree(egg_infodir, dry_run=self.dry_run)
                else:
                    log.warn("'%s' does not exist -- can't clean it", egg_infodir)

        # Remove build directories
        if self.all:
            for directory in (self.build_exe,):
                if os.path.exists(directory):
                    remove_tree(directory, dry_run=self.dry_run)
                else:
                    log.warn("'%s' does not exist -- can't clean it",
                             directory)

        # Purge
        if self.purge:
            if os.path.exists(self.dist_dir):
                remove_tree(self.dist_dir, dry_run=self.dry_run)
            else:
                log.warn("'%s' does not exist -- can't clean it", self.dist_dir)
Пример #4
0
 def run(self):
     import subprocess
     subprocess.call(["make", "-f", "Makefile", "clean"],
                     cwd=XPALIB_DIR)
     if os.path.exists(CONF_H_NAME):
         os.remove(CONF_H_NAME)
     _clean.run(self)
Пример #5
0
 def run(self):
     _clean.run(self)
     for x in ['kudu/client.cpp']:
         try:
             os.remove(x)
         except OSError:
             pass
Пример #6
0
 def run(self):
     Clean.run(self)
     # Remove c files if we are not within a sdist package
     cwd = os.path.abspath(os.path.dirname(__file__))
     remove_c_files = not os.path.exists(os.path.join(cwd, 'PKG-INFO'))
     if remove_c_files:
         cython_hash_file = os.path.join(cwd, 'cythonize.dat')
         if os.path.exists(cython_hash_file):
             os.unlink(cython_hash_file)
         print('Will remove generated .c files')
     if os.path.exists('build'):
         shutil.rmtree('build')
     for dirpath, dirnames, filenames in os.walk('sklearn'):
         for filename in filenames:
             if any(filename.endswith(suffix) for suffix in
                    (".so", ".pyd", ".dll", ".pyc")):
                 os.unlink(os.path.join(dirpath, filename))
                 continue
             extension = os.path.splitext(filename)[1]
             if remove_c_files and extension in ['.c', '.cpp']:
                 pyx_file = str.replace(filename, extension, '.pyx')
                 if os.path.exists(os.path.join(dirpath, pyx_file)):
                     os.unlink(os.path.join(dirpath, filename))
         for dirname in dirnames:
             if dirname == '__pycache__':
                 shutil.rmtree(os.path.join(dirpath, dirname))
Пример #7
0
 def run(self):
     _clean.run(self)
     for x in ['feather/ext.cpp']:
         try:
             os.remove(x)
         except OSError:
             pass
Пример #8
0
    def run(self):
        _clean.run(self)

        import fnmatch

        # kill temporary files
        patterns = [
            # generic tempfiles
            '*~', '*.bak', '*.pyc',

            # tempfiles generated by ANTLR runs
            't[0-9]*Lexer.py', 't[0-9]*Parser.py',
            '*.tokens', '*__.g',
            ]

        for path in ('antlr3', 'unittests', 'tests'):
            path = os.path.join(os.path.dirname(__file__), path)
            if os.path.isdir(path):
                for root, dirs, files in os.walk(path, topdown=True):
                    graveyard = []
                    for pat in patterns:
                        graveyard.extend(fnmatch.filter(files, pat))

                    for name in graveyard:
                        filePath = os.path.join(root, name)

                        try:
                            log.info("removing '%s'", filePath)
                            os.unlink(filePath)
                        except OSError, exc:
                            log.warn(
                                "Failed to delete '%s': %s",
                                filePath, exc
                                )
Пример #9
0
	def run(self):
		if self.all:
			self.clean_tests()
			self.clean_docs()
			self.clean_man()

		clean.run(self)
Пример #10
0
 def run(self):
     if self.all:
         for (filename, template) in self.distribution.netsa_version_files:
             log.info("removing %r", filename)
             if not self.dry_run:
                 try:
                     os.unlink(filename)
                 except:
                     log.debug("%r doesn't exist -- can't clean it",
                               filename)
         html_dir = self.get_finalized_command('gen_doc_html').gen_doc_html
         if os.path.exists(html_dir):
             remove_tree(html_dir, dry_run=self.dry_run)
         pdf_file = self.get_finalized_command('gen_doc_pdf').gen_doc_pdf
         log.info("removing %r", pdf_file)
         if not self.dry_run:
             try:
                 os.unlink(pdf_file)
             except:
                 log.debug("%r doesn't exist -- can't clean it",
                           pdf_file)
     latex_dir = self.get_finalized_command('gen_doc_pdf').gen_doc_latex
     extra_dir = self.get_finalized_command('gen_doc_pdf').gen_doc_extra
     if os.path.exists(latex_dir):
         remove_tree(latex_dir, dry_run=self.dry_run)
     if os.path.exists(extra_dir):
         remove_tree(extra_dir, dry_run=self.dry_run)
     clean.run(self)
Пример #11
0
    def run(self):
        # call base class clean
        clean.run(self)

        # clean remaining cython/cpp files
        t_path = [
            os.path.join(SETUP_PATH, "gnome", "cy_gnome"),
            os.path.join(SETUP_PATH, "gnome", "utilities", "geometry"),
        ]
        exts = ["*.so", "cy_*.pyd", "cy_*.cpp", "cy_*.c"]

        for temp in t_path:
            for ext in exts:
                for f in glob.glob(os.path.join(temp, ext)):
                    print "Deleting auto-generated file: {0}".format(f)
                    try:
                        if os.path.isdir(f):
                            shutil.rmtree(f)
                        else:
                            os.remove(f)
                    except OSError as err:
                        print ("Failed to remove {0}. Error: {1}".format(f, err))
                        # raise

        rm_dir = ["pyGnome.egg-info", "build"]
        for dir_ in rm_dir:
            print "Deleting auto-generated directory: {0}".format(dir_)
            try:
                shutil.rmtree(dir_)
            except OSError as err:
                print ("Failed to remove {0}. Error: {1}".format(dir_, err))
Пример #12
0
 def run(self):
     _clean.run(self)
     for x in []:
         try:
             os.remove(x)
         except OSError:
             pass
Пример #13
0
            def run(self):
                # Recursive deletion of build/ directory
                path = localpath("build")
                try:
                    shutil.rmtree(path)
                except Exception:
                    print("Error: Failed to remove directory %s" % path)
                else:
                    print("Success: Cleaned up %s" % path)

                # Now, the extension and other files
                try:
                    import imp
                except ImportError:
                    if os.name == 'posix':
                        paths = [localpath("zorro/numexprz/interpreter.so")]
                    else:
                        paths = [localpath("zorro/numexprz/interpreter.pyd")]
                else:
                    paths = []
                    for suffix, _, _ in imp.get_suffixes():
                        if suffix == '.py':
                            continue
                        paths.append(localpath("zorro/numexprz", "interpreter" + suffix))
                paths.append(localpath("zorro/numexprz/__config__.py"))
                paths.append(localpath("zorro/numexprz/__config__.pyc"))
                for path in paths:
                    try:
                        os.remove(path)
                    except Exception:
                        print("Error: Failed to clean up file %s" % path)
                    else:
                        print("Cleaning up %s" % path)

                clean.run(self)
Пример #14
0
 def run(self):
     if self.all:
         # remove dist
         if os.path.exists('dist'):
             remove_tree('dist')
         else:
             log.warn("'dist' does not exist -- can't clean it")
         # remove docs
         sphinx_dir = os.path.join(self.build_base, 'sphinx')
         if os.path.exists(sphinx_dir):
             remove_tree(sphinx_dir, dry_run=self.dry_run)
         else:
             log.warn("%r does not exist -- can't clean it", sphinx_dir)
         # remove setup eggs
         for egg in glob.glob('*.egg') + glob.glob('*.egg-info'):
             if os.path.isdir(egg):
                 remove_tree(egg, dry_run=self.dry_run)
             else:
                 log.info('removing %r' % egg)
                 os.unlink(egg)
         # remove Portfile
         portfile = 'Portfile'
         if os.path.exists(portfile) and not self.dry_run:
             log.info('removing %r' % portfile)
             os.unlink(portfile)
     clean.run(self)
Пример #15
0
    def run(self):
        # distutils uses old-style classes???
        #super(Clean, self).run()
        clean.run(self)

        clean_pyc_files(self.dry_run)

        # clean inplace so files that are not in ext_modules
        # this will clean old object files if cython modules move
        so_file_list = []
        for ext in self.distribution.ext_modules:
            fn = os.path.join(*ext.name.split('.')) + ".so"
            so_file_list.append(os.path.abspath(fn))
        clean_other_so_files(so_file_list, self.dry_run)

        if self.all:
            # remove inplace extensions
            for ext in self.distribution.ext_modules:
                fn = os.path.join(*ext.name.split('.'))
                files = [fn + ".so", fn + ".pyd"]
                for fn in files:
                    if os.path.isfile(fn):
                        log.info("removing '{0}'".format(fn))
                        os.unlink(fn)

                # remove c files if has_cython
                if has_cython and use_cython:
                    for f in ext.sources:
                        if f[-4:] == ".pyx":
                            for rm_ext in ['.c', '.cpp']:
                                fn = f[:-4] + rm_ext
                                if os.path.isfile(fn):
                                    log.info("removing '{0}'".format(fn))
                                    os.unlink(fn)
Пример #16
0
    def run(self):

        base.run(self)

        if self.all:

            # Remove the build/clib.<plat> directory (unless it's already
            # gone).
            libdir = os.path.join(self.build_clib, 'lib')
            incdir = os.path.join(self.build_clib, 'include')
            bindir = os.path.join(self.build_clib, 'bin')
            for d in [libdir, incdir, bindir]:
                if os.path.exists(d):
                    remove_tree(d, dry_run=self.dry_run)
            pc = os.path.join(self.build_clib, 'synopsis.pc')
            if os.path.exists(pc) and not self.dry_run:
                os.remove(pc)

            # Remove the generated documentation.
            prefix = 'share/doc/synopsis/html/Manual'
            for d in ['cxx', 'python', 'sxr']:
                if os.path.exists(os.path.join(prefix, d)):
                    remove_tree(os.path.join(prefix, d), dry_run=self.dry_run)

            prefix = 'share/doc/synopsis/html'
            for d in ['Tutorial', 'DevGuide']:
                if os.path.exists(os.path.join(prefix, d)):
                    remove_tree(os.path.join(prefix, d), dry_run=self.dry_run)

            prefix = 'share/doc/synopsis'
            if os.path.exists(os.path.join(prefix, 'examples')):
                remove_tree(os.path.join(prefix, 'examples'), dry_run=self.dry_run)
Пример #17
0
 def run(self):
     # remove schema data and then do any other normal cleaning
     try:
         shutil.rmtree(eulxml.XMLCATALOG_DIR)
     except OSError:
         pass
     clean.run(self)
Пример #18
0
    def run(self):
        _CleanCommand.run(self)

        dir_names = set()
        if self.dist:
            for cmd_name, _ in self.distribution.get_command_list():
                if 'dist' in cmd_name:
                    command = self.distribution.get_command_obj(cmd_name)
                    command.ensure_finalized()
                    if getattr(command, 'dist_dir', None):
                        dir_names.add(command.dist_dir)

        if self.eggs:
            for name in os.listdir(self.egg_base):
                if name.endswith('.egg-info'):
                    dir_names.add(os.path.join(self.egg_base, name))
            for name in os.listdir(os.curdir):
                if name.endswith('.egg'):
                    dir_names.add(name)

        if self.environment and self.virtualenv_dir:
            dir_names.add(self.virtualenv_dir)

        if self.pycache:
            for root, dirs, _ in os.walk(os.curdir):
                if '__pycache__' in dirs:
                    dir_names.add(os.path.join(root, '__pycache__'))

        for dir_name in dir_names:
            if os.path.exists(dir_name):
                dir_util.remove_tree(dir_name, dry_run=self.dry_run)
            else:
                self.announce(
                    'skipping {0} since it does not exist'.format(dir_name))
Пример #19
0
 def run(self):
     if self.all:
         # remove dist
         if os.path.exists("dist"):
             remove_tree("dist")
         else:
             log.warn("'dist' does not exist -- can't clean it")
         # remove docs
         sphinx_dir = os.path.join(self.build_base, "sphinx")
         if os.path.exists(sphinx_dir):
             remove_tree(sphinx_dir, dry_run=self.dry_run)
         else:
             log.warn("%r does not exist -- can't clean it", sphinx_dir)
         # remove version.py
         for vpy in [VERSION_PY, VERSION_PY + "c"]:
             if os.path.exists(vpy) and not self.dry_run:
                 log.info("removing %r" % vpy)
                 os.unlink(vpy)
             elif not os.path.exists(vpy):
                 log.warn("%r does not exist -- can't clean it", vpy)
         # remove setup eggs
         for egg in glob.glob("*.egg"):
             if os.path.isdir(egg):
                 remove_tree(egg, dry_run=self.dry_run)
             else:
                 log.info("removing %r" % egg)
                 os.unlink(egg)
         # remove Portfile
         portfile = "Portfile"
         if os.path.exists(portfile) and not self.dry_run:
             log.info("removing %r" % portfile)
             os.unlink(portfile)
     clean.run(self)
Пример #20
0
 def run(self):
     clean.run(self)
     path = os.path.join(here_dir, 'llvmlite.egg-info')
     if os.path.isdir(path):
         remove_tree(path, dry_run=self.dry_run)
     if not self.dry_run:
         self._rm_walk()
Пример #21
0
 def run(self):
     if self.all:
         # remove docs
         sphinx_dir = os.path.join(self.build_base, 'sphinx')
         if os.path.exists(sphinx_dir):
             remove_tree(sphinx_dir, dry_run=self.dry_run)
         else:
             log.warn("%r does not exist -- can't clean it", sphinx_dir)
         # remove version.py
         for vpy in [VERSION_PY, VERSION_PY + 'c']:
             if os.path.exists(vpy) and not self.dry_run:
                 log.info('removing %r' % vpy)
                 os.unlink(vpy)
             elif not os.path.exists(vpy):
                 log.warn("%r does not exist -- can't clean it", vpy)
         # remove setup eggs
         for egg in glob.glob('*.egg'):
             if os.path.isdir(egg):
                 remove_tree(egg, dry_run=self.dry_run)
             else:
                 log.info('removing %r' % egg)
                 os.unlink(egg)
         # remove Portfile
         portfile = 'Portfile'
         if os.path.exists(portfile) and not self.dry_run:
             log.info('removing %r' % portfile)
             os.unlink(portfile)
     clean.run(self)
Пример #22
0
	def run(self):
		clean.run(self)
		# clean ui generated .py files
		for f in qt_ui_files():
			f = py_file_name(f)
			if os.path.exists(f):
				os.unlink(f)
 def run(self):
     # remove zip file and then do any other normal cleaning
     try:
         os.remove(ZIPFILE_PATH)
     except OSError:
         pass
     clean.run(self)
Пример #24
0
 def run(self):
     if self.all:
         for (filename, template) in self.distribution.netsa_version_files:
             if os.path.exists(filename):
                 log.info("removing %r", filename)
                 if not self.dry_run:
                     os.unlink(filename)
         if self.distribution.netsa_doc_dir:
          html_dir = self.get_finalized_command('gen_doc_html').gen_doc_html
          if os.path.exists(html_dir):
              remove_tree(html_dir, dry_run=self.dry_run)
          pdf_file = self.get_finalized_command('gen_doc_pdf').gen_doc_pdf
          if os.path.exists(pdf_file):
              log.info("removing %r", pdf_file)
              if not self.dry_run:
                  os.unlink(pdf_file)
     if self.distribution.netsa_doc_dir:
         latex_dir = self.get_finalized_command('gen_doc_pdf').gen_doc_latex
         extra_dir = self.get_finalized_command('gen_doc_pdf').gen_doc_extra
         web_dir = self.get_finalized_command(
             'gen_doc_tools_web').gen_doc_web
         gen_man_dir = self.get_finalized_command('gen_doc_man').gen_doc_man
         man_base = os.path.join(self.distribution.source_dir,
                                 self.distribution.netsa_doc_dir, "man")
         if os.path.exists(latex_dir):
             remove_tree(latex_dir, dry_run=self.dry_run)
         if os.path.exists(extra_dir):
             remove_tree(extra_dir, dry_run=self.dry_run)
         if os.path.exists(web_dir):
             remove_tree(web_dir, dry_run=self.dry_run)
         if os.path.exists(gen_man_dir):
             remove_tree(gen_man_dir, dry_run=self.dry_run)
         if os.path.exists(man_base):
             remove_tree(man_base, dry_run=self.dry_run)
     clean.run(self)
Пример #25
0
 def run(self):
     clean.run(self)
     if self.sources:
         if os.path.exists('src'):
             remove_tree('src', dry_run=self.dry_run)
         else:
             log.info("'%s' does not exist -- can't clean it", 'src')
Пример #26
0
 def run(self):
   if self.all:
     if os.path.exists(self.build_doc):
       remove_tree(self.build_doc, dry_run=self.dry_run)
     else:
       log.debug("%s doesn't exist -- can't clean it", self.build_doc)
   _clean.run(self)
Пример #27
0
    def run(self):
        # call base class clean
        clean.run(self)

        # clean remaining cython/cpp files
        t_path = [os.path.join(SETUP_PATH, 'py_gd')]
        exts = ['*.so', 'cy_*.pyd', 'cy_*.cpp', 'cy_*.c']

        for temp in t_path:
            for ext in exts:
                for f in glob.glob(os.path.join(temp, ext)):
                    print("Deleting auto-generated file: {0}".format(f))
                    try:
                        if os.path.isdir(f):
                            shutil.rmtree(f)
                        else:
                            os.remove(f)
                    except OSError as err:
                        print("Failed to remove {0}. Error: {1}"
                              .format(f, err))
                        # raise

        rm_dir = ['py_gd.egg-info', 'build']
        for dir_ in rm_dir:
            print("Deleting auto-generated directory: {0}".format(dir_))
            try:
                shutil.rmtree(dir_)
            except OSError as err:
                if err.errno != 2:  # ignore the not-found error
                    raise
Пример #28
0
    def run(self):
        # do the normal cleanup
        clean.run(self)

        # try to remove '_composite.{so,pyd,...}' extension,
        # regardless of the current system's extension name convention
        build_ext = self.get_finalized_command('build_ext')
        ext_fname = build_ext.get_ext_filename('overviewer_core.c_overviewer')
        versionpath = os.path.join("overviewer_core", "overviewer_version.py")
        primspath = os.path.join("overviewer_core", "src", "primitives.h")

        for fname in [ext_fname, primspath]:
            if os.path.exists(fname):
                try:
                    log.info("removing '%s'", fname)
                    if not self.dry_run:
                        os.remove(fname)

                except OSError:
                    log.warn("'%s' could not be cleaned -- permission denied",
                             fname)
            else:
                log.debug("'%s' does not exist -- can't clean it",
                          fname)

        # now try to purge all *.pyc files
        for root, dirs, files in os.walk(os.path.join(os.path.dirname(__file__), ".")):
            for f in files:
                if f.endswith(".pyc"):
                    if self.dry_run:
                        log.warn("Would remove %s", os.path.join(root,f))
                    else:
                        os.remove(os.path.join(root, f))
Пример #29
0
 def run(self):
     _clean.run(self)
     dist_dir = ['bdist', 'build', 'dist']
     full_name = self.distribution.get_fullname()
     for dist in dist_dir:
         if os.path.isdir(dist):
             _remove_tree(dist, dry_run=self.dry_run)
Пример #30
0
 def run(self):
     clean.run(self)
     files = [
         "omnivore/*/*.so",
         "omnivore/*/*.pyd",
         "omnivore/*/*/*.so",
         "omnivore/*/*/*.pyd",
         "omnivore/arch/antic_speedups.c",
         "omnivore/disassembler/cputables.py",
         "lib6502/lib6502.c",
         "libatari800/libatari800.c",
         "libatasm/libatasm.c",
         "libudis/declarations.pyx",
         "libudis/declarations.c",
         "libudis/libudis.c",
         "libudis/parse_udis_cpu.c",
         "libudis/stringify_udis_cpu.c",
         "libudis/stringify_udis_cpu.h",
     ]
     for pathspec in files:
         for path in glob.glob(pathspec):
             print(f"cleaning {path}")
             try:
                 os.unlink(path)
             except OSError:
                 pass
Пример #31
0
    def run(self):
        # do the normal cleanup
        clean.run(self)

        # try to remove '_composite.{so,pyd,...}' extension,
        # regardless of the current system's extension name convention
        build_ext = self.get_finalized_command('build_ext')
        pretty_fname = build_ext.get_ext_filename(
            'overviewer_core.c_overviewer')
        fname = pretty_fname
        if os.path.exists(fname):
            try:
                if not self.dry_run:
                    os.remove(fname)
                log.info("removing '%s'", pretty_fname)
            except OSError:
                log.warn("'%s' could not be cleaned -- permission denied",
                         pretty_fname)
        else:
            log.debug("'%s' does not exist -- can't clean it", pretty_fname)

        versionpath = os.path.join("overviewer_core", "overviewer_version.py")
        if os.path.exists(versionpath):
            try:
                if not self.dry_run:
                    os.remove(versionpath)
                log.info("removing '%s'", versionpath)
            except OSError:
                log.warn("'%s' could not be cleaned -- permission denied",
                         versionpath)
        else:
            log.debug("'%s' does not exist -- can't clean it", versionpath)

        # now try to purge all *.pyc files
        for root, dirs, files in os.walk(
                os.path.join(os.path.dirname(__file__), ".")):
            for f in files:
                if f.endswith(".pyc"):
                    if self.dry_run:
                        log.warn("Would remove %s", os.path.join(root, f))
                    else:
                        os.remove(os.path.join(root, f))
Пример #32
0
    def run(self):

        if os.path.exists('build'):
            shutil.rmtree('build')

        for dirpath, dirnames, filenames in os.walk('.'):
            for filename in filenames:
                if any(filename.endswith(suffix) for suffix in
                       (".so", ".pyd", ".dll", ".pyc")):
                    os.unlink(os.path.join(dirpath, filename))
                    continue
                extension = os.path.splitext(filename)[1]
                if extension in ['.c', '.cpp']:
                    pyx_file = str.replace(filename, extension, '.pyx')
                    if os.path.exists(os.path.join(dirpath, pyx_file)):
                        os.unlink(os.path.join(dirpath, filename))
            for dirname in dirnames:
                if dirname == '__pycache__':
                    shutil.rmtree(os.path.join(dirpath, dirname))
        clean.run(self)
Пример #33
0
    def run(self):
        functions_py = os.path.join(os.path.dirname(__file__), "csvn", "core",
                                    "functions.py")
        functions_pyc = os.path.join(os.path.dirname(__file__), "csvn", "core",
                                     "functions.pyc")
        svn_all_py = os.path.join(os.path.dirname(__file__), "svn_all.py")
        svn_all2_py = os.path.join(os.path.dirname(__file__), "svn_all2.py")

        for f in (functions_py, functions_pyc, svn_all_py, svn_all2_py):
            if os.path.exists(f):
                log.info("removing '%s'", os.path.normpath(f))

                if not self.dry_run:
                    os.remove(f)
            else:
                log.debug("'%s' does not exist -- can't clean it",
                          os.path.normpath(f))

        # Run standard clean command
        _clean.run(self)
Пример #34
0
 def run(self):
     Clean.run(self)
     if os.path.exists('build'):
         shutil.rmtree('build')
     for dirpath, dirnames, filenames in os.walk('.'):
         for filename in filenames:
             if ((filename.endswith('.so')
                  and not filename.startswith('libmkl_core.'))
                     or filename.endswith('.pyd')
                     or (use_cython and filename.find("wrap_qfc.cpp") != -1
                         )  # remove automatically generated source file
                     or (use_cython and filename.find("cample.cpp") != -1
                         )  # remove automatically generated source file
                     or
                 (use_cython and filename.find("mmultfilex.cpp") != -1
                  )  # remove automatically generated source file
                     or filename.endswith('.pyc')):
                 tmp_fn = os.path.join(dirpath, filename)
                 print "removing", tmp_fn
                 os.unlink(tmp_fn)
Пример #35
0
    def run(self):
        _clean.run(self)
        for ext in self.distribution.ext_modules:
            cy_sources = [s for s in ext.sources if s.endswith('.pyx')]
            for cy_source in cy_sources:
                c_source = cy_source[:-3] + 'c'
                if osp.exists(c_source):
                    log.info('removing %s', c_source)
                    os.remove(c_source)
                so_built = cy_source[:-3] + 'so'
                if osp.exists(so_built):
                    log.info('removing %s', so_built)
                    os.remove(so_built)

        # Check if we need to remove the freetds directory
        if WINDOWS:
            # If the directory exists, remove it
            if osp.isdir(FREETDS):
                import shutil
                shutil.rmtree(FREETDS)
Пример #36
0
    def run(self):
        _clean.run(self)

        # clean sphinx documentation:
        cmd = ['make', '-C', 'doc', 'clean']
        p = Popen(cmd)
        p.communicate()

        coverage = os.path.join('doc', 'coverage')
        generated = os.path.join('doc', 'gen')

        if os.path.exists(coverage):
            print('rm -r %s' % coverage)
            shutil.rmtree(os.path.join('doc', 'coverage'))
        if os.path.exists(generated):
            print('rm -r %s' % generated)
            shutil.rmtree(generated)
        if os.path.exists('MANIFEST'):
            print('rm MANIFEST')
            os.remove('MANIFEST')
Пример #37
0
    def run(self):
        clean.run(self)
        if is_git_tree():
            print(run_git('clean -fdX' + ('n' if self.dry_run else '')))
            return

        dirs = 'build', self.distribution.get_name() + '.egg-info'
        for d in dirs:
            f = os.path.join(root, d)
            if os.path.exists(f):
                self.__delete(f, dir=True)

        extensions = '.o', '.pyc', 'pyd', 'pyo', '.so'
        for root_, dirs, files in os.walk(root):
            for f in files:
                if os.path.splitext(f)[-1] in extensions:
                    self.__delete(os.path.join(root_, f))
            for d in dirs:
                if d == '__pycache__':
                    self.__delete(os.path.join(root_, d), dir=True)
Пример #38
0
    def run(self):
        # do the normal cleanup
        clean.run(self)

        # try to remove 'OIL.{so,pyd,...}' extension,
        # regardless of the current system's extension name convention
        build_ext = self.get_finalized_command('build_ext')
        fname = build_ext.get_ext_filename('OIL')
        if os.path.exists(fname):
            try:
                log.info("removing '%s'", fname)
                if not self.dry_run:
                    os.remove(fname)
                    
            except OSError:
                log.warn("'%s' could not be cleaned -- permission denied",
                         fname)
        else:
            log.debug("'%s' does not exist -- can't clean it",
                      fname)
Пример #39
0
    def run(self):
        _clean.run(self)
        if self.orig:
            return

        # eggs
        if not self.noeggs:
            for egg in self.eggs:
                globbed_eggs = glob.glob(egg)
                for globbed_egg in globbed_eggs:
                    print("deleting '%s' egg" % globbed_egg)
                    if not self.dry_run:
                        shutil.rmtree(globbed_egg)

        # pyc files
        if not self.nopyc:

            def delete_folder_if_empty(path, applied_handler):
                if not applied_handler:
                    return
                if len(os.listdir(path)) == 0:
                    if not self.dry_run:
                        shutil.rmtree(path)
                    print("removed %s since it was empty" %
                          path[len(self.source_folder):])

            def delete_file(path):
                print("removing '%s'" % path[len(self.source_folder):])
                if not self.dry_run:
                    os.remove(path)

            import fnmatch

            print("recursively removing *.pyc from '%s'" % self.source_folder)
            recursively_handle_files(
                os.path.abspath(self.source_folder),
                lambda name: fnmatch.fnmatch(name.lower(), "*.pyc"),
                folder_matcher=lambda dir, name, path: name != ".git",
                folder_handler=delete_folder_if_empty,
                file_handler=delete_file,
            )
Пример #40
0
    def run(self):
        _CleanCommand.run(self)

        dir_names = set()
        if self.build:
            dir_names.update(
                _gather_attributes(
                    self.distribution,
                    lambda cmd_name: cmd_name.startswith('build'),
                    'build_base', 'build_clib', 'build_dir', 'build_lib',
                    'build_temp'))

        if self.dist:
            dir_names.update(
                _gather_attributes(self.distribution,
                                   lambda cmd_name: 'dist' in cmd_name,
                                   'dist_dir'))

        if self.eggs:
            for name in os.listdir(self.egg_base):
                if name.endswith('.egg-info'):
                    dir_names.add(os.path.join(self.egg_base, name))
            for name in os.listdir(os.curdir):
                for e in ['.egg', '.eggs', '.egg-info']:  # FIXME
                    if name.endswith(e):
                        dir_names.add(name)

        if self.environment and self.virtualenv_dir:
            dir_names.add(self.virtualenv_dir)

        if self.pycache:
            for root, dirs, _ in os.walk(os.curdir):
                if '__pycache__' in dirs:
                    dir_names.add(os.path.join(root, '__pycache__'))

        for dir_name in dir_names:
            if os.path.exists(dir_name):
                dir_util.remove_tree(dir_name, dry_run=self.dry_run)
            else:
                self.announce(
                    'skipping {0} since it does not exist'.format(dir_name))
Пример #41
0
    def run(self):
        clean.run(self)

        print('extra clean:')
        suffixes = [
            '*.pyc', '*.o', '*.so', '*.pyd', '*_wrap.c', '*.bak', '*~', '*%'
        ]
        for filename in recursive_glob('sfepy', suffixes):
            print(filename)
            os.remove(filename)

        for filename in recursive_glob('examples', suffixes):
            print(filename)
            os.remove(filename)

        for filename in recursive_glob('script', suffixes):
            print(filename)
            os.remove(filename)

        for filename in recursive_glob('tests', suffixes):
            print(filename)
            os.remove(filename)

        for filename in glob.glob('*.pyc'):
            print(filename)
            os.remove(filename)

        for _filename in recursive_glob('sfepy', ['*.pyx']):
            filename = _filename.replace('.pyx', '.c')
            print(filename)
            try:
                os.remove(filename)
            except OSError:
                pass

            filename = _filename.replace('.pyx', '.html')
            print(filename)
            try:
                os.remove(filename)
            except OSError:
                pass
Пример #42
0
    def run(self):
        import glob
        import re
        with open('.gitignore', 'r') as f:
            ignores = f.read()
            pat = re.compile(r'^#( BEGIN NOT-CLEAN-FILES )?')
            for wildcard in filter(None, ignores.split('\n')):
                match = pat.match(wildcard)
                if match:
                    if match.group(1):
                        # Marker is found and stop reading .gitignore.
                        break
                    # Ignore lines which begin with '#'.
                else:
                    for filename in glob.glob(wildcard):
                        try:
                            os.remove(filename)
                        except OSError:
                            shutil.rmtree(filename, ignore_errors=True)

        clean.run(self)
Пример #43
0
    def run(self):
        # Call parent method
        clean_command.run(self)

        # Clean setuptools-generated directories
        st_dirs = ['dist', 'build', 'geomdl.egg-info']

        print("Removing setuptools-generated directories")
        for d in st_dirs:
            d_path = os.path.join(os.path.dirname(__file__), d)
            shutil.rmtree(d_path, ignore_errors=True)

        # Find list of files with .c extension
        flist, flist_path = read_files("geomdl", ".c")

        # Clean files with .c extensions
        if flist_path:
            print("Removing Cython-generated source files")
            for f in flist_path:
                f_path = os.path.join(os.path.dirname(__file__), f)
                os.unlink(f_path)
Пример #44
0
 def run(self):
     if self.all:
         # remove dist
         if os.path.exists('dist'):
             remove_tree('dist')
         else:
             log.warn("'dist' does not exist -- can't clean it")
         # remove docs
         sphinx_dir = os.path.join(self.build_base, 'sphinx')
         if os.path.exists(sphinx_dir):
             remove_tree(sphinx_dir, dry_run=self.dry_run)
         else:
             log.warn("%r does not exist -- can't clean it", sphinx_dir)
         # remove setup eggs
         for egg in glob.glob('*.egg') + glob.glob('*.egg-info'):
             if os.path.isdir(egg):
                 remove_tree(egg, dry_run=self.dry_run)
             else:
                 log.info('removing %r' % egg)
                 os.unlink(egg)
     orig_clean.run(self)
Пример #45
0
    def run(self):

        Clean.run(self)

        if os.path.exists('build'):
            shutil.rmtree('build')

        for dirpath, dirnames, filenames in os.walk('.'):
            for filename in filenames:
                if (filename.endswith('.so') or filename.endswith('.pyd')
                        or filename.endswith('.pyc')
                        or filename.endswith('_wrap.c')
                        or filename.startswith('wrapper_')
                        or filename.endswith('~')):
                    os.unlink(os.path.join(dirpath, filename))

            for dirname in dirnames:
                if dirname == '__pycache__' or dirname == 'build':
                    shutil.rmtree(os.path.join(dirpath, dirname))
                if dirname == "pymscons.egg-info":
                    shutil.rmtree(os.path.join(dirpath, dirname))
Пример #46
0
    def run(self):
        ## Setup files.
        platform_type = platform.system()
        if platform_type == "Darwin":
            lib_extension = "dylib"
        elif platform_type == "Linux":
            lib_extension = "so"
        else:
            print("Unknown platform type: {}".format(platform_type))
            exit(1)

        os.remove(makefile)

        ## Run make
        os.system("make clean")

        # make the faiss python package dir
        shutil.rmtree("faiss", ignore_errors=True)

        # Run base clean.
        clean.run(self)
Пример #47
0
 def run(self):
     Clean.run(self)
     # Remove c files if we are not within a sdist package
     cwd = os.path.abspath(os.path.dirname(__file__))
     remove_c_files = not os.path.exists(os.path.join(cwd, 'PKG-INFO'))
     if os.path.exists('build'):
         shutil.rmtree('build')
     for root, dirs, files in os.walk('esahub'):
         for filename in files:
             if any(filename.endswith(suffix) for suffix in
                    (".so", ".pyd", ".dll", ".pyc")):
                 os.unlink(os.path.join(root, filename))
                 continue
             extension = os.path.splitext(filename)[1]
             if remove_c_files and extension in ['.c', '.cpp']:
                 pyx_file = str.replace(filename, extension, '.pyx')
                 if os.path.exists(os.path.join(root, pyx_file)):
                     os.unlink(os.path.join(root, filename))
         for dirname in dirs:
             if dirname == '__pycache__':
                 shutil.rmtree(os.path.join(root, dirname))
Пример #48
0
    def run(self):
        _clean.run(self)

        self.__clean_tree(os.path.join(HERE, 'pyrobuf'))
        self.__clean_tree(os.path.join(HERE, 'tests'))

        tests_out = os.path.join(HERE, 'tests', 'out')
        if os.path.isdir(tests_out):
            remove_tree(tests_out, verbose=self.verbose, dry_run=self.dry_run)

        self.__remove_file(
            os.path.join(HERE, 'pyrobuf', 'src', PYROBUF_LIST_PXD))
        self.__remove_file(
            os.path.join(HERE, 'pyrobuf', 'src', PYROBUF_LIST_PYX))

        for filename in os.listdir(HERE):
            for prefix in ("pyrobuf_list", "pyrobuf_util"):
                for suffix in (".so", ".pyd"):
                    if filename.startswith(prefix) and filename.endswith(
                            suffix):
                        self.__remove_file(os.path.join(HERE, filename))
Пример #49
0
    def run(self):
        "the entry point for the distutils clean class"
        sys.stdout.write(blue("Cleaning headers:"))
        dir_gen = os.walk("Inventor")
        for _dir, _, names in dir_gen:
            self.remove_headers(None, _dir, names)

        dir_gen = os.walk("VolumeViz")
        for _dir, _, names in dir_gen:
            self.remove_headers(None, _dir, names)

        self.remove_cmake()

        # remove the SWIG generated wrappers
        for wrapper_file in self.REMOVE_FILES:
            if os.path.isfile(wrapper_file):
                sys.stdout.write(' ' + turquoise(wrapper_file))
                os.remove(wrapper_file)
        print(green("."))

        clean.run(self)
Пример #50
0
    def run(self):
        clean_cmd.run(self)
        to_be_removed = [
            "build/", "dist/", "MANIFEST", cpp_dir,
            "{}.egg-info".format(PACKAGE_NAME)
        ]
        to_be_removed += glob("./{}/{}.*".format(PACKAGE_DIR,
                                                 dynamic_lib_name))
        for root, dirs, files in os.walk(os.curdir, topdown=False):
            if "__pycache__" in dirs:
                to_be_removed.append(path.join(root, "__pycache__"))
            to_be_removed += [f for f in files if f.endswith(".pyc")]

        for f in to_be_removed:
            print("remove {}".format(f))
            if f == ".":
                continue
            elif path.isfile(f):
                os.remove(f)
            elif path.isdir(f):
                rmtree(f)
Пример #51
0
    def run(self):
        dftclean.run(self)

        # This is a very crude approach to clean the garbage created by taurus
        # outside of the build dir when running the build command
        # see: https://sourceforge.net/p/sardana/tickets/324/
        import glob
        from distutils.dir_util import remove_tree

        # collect the garbage *files* to be deleted
        garbage = []

        resource = abspath('lib', 'taurus', 'qt', 'qtgui', 'resource')
        garbage.extend(glob.glob(os.path.join(resource, '*.rcc')))
        garbage.extend(glob.glob(os.path.join(resource, '*.qrc')))
        garbage.append(os.path.join(resource, 'catalog.html'))

        doc_devel = abspath('doc', 'source', 'devel')
        garbage.append(os.path.join(doc_devel, 'catalog.html'))

        doc = abspath('doc')
        garbage.append(os.path.join(doc, '~thumbnails.zip'))

        # delete the garbage files
        for fn in garbage:
            if os.path.exists(fn):
                log.info("removing '%s'", fn)
                if self.dry_run:
                    continue
                os.remove(fn)
            else:
                log.debug("'%s' does not exist -- can't clean it", fn)

        # now delete the api dir
        api_dir = os.path.join(doc_devel, 'api')
        if os.path.exists(api_dir):
            remove_tree(api_dir, dry_run=self.dry_run)
        else:
            log.debug("'%s' does not exist -- can't clean it", api_dir)
Пример #52
0
    def run(self):

        clean.run(self)

        # remove hidden '~' files
        for dirpath, dirnames, filenames in os.walk('.'):
            for filename in filenames:
                if filename.endswith('~') or filename.endswith('.pyc'):
                    os.unlink(os.path.join(dirpath, filename))

        # build related files and directories
        if os.path.exists('build'):
            shutil.rmtree('build')
        if os.path.exists('woody.egg-info'):
            shutil.rmtree('woody.egg-info')
        if os.path.exists('docs/_build'):
            shutil.rmtree('docs/_build')

        # remaining files and directories in woody dir (recursively)
        for dirpath, dirnames, filenames in os.walk('woody'):
            
            for filename in filenames:
                if (filename.endswith('.so') or 
                    filename.endswith('.pyd') or 
                    filename.endswith('.dll') or 
                    filename.endswith('.pyc') or 
                    filename.endswith('_wrap.c') or 
                    filename.startswith('wrapper_') or 
                    filename.endswith('~')):
                        os.unlink(os.path.join(dirpath, filename))

            for dirname in dirnames:
                if dirname == '__pycache__' or dirname == 'build' or dirname == '_build':
                    shutil.rmtree(os.path.join(dirpath, dirname))

        try:
            shutil.rmtree("dist")
        except:
            pass
Пример #53
0
    def run(self):
        self.clean_test_data()

        remove_files = list(self.temporary_files)
        if self.all:
            remove_files = remove_files + self.nontemporary_files

        for filename in remove_files:
            if callable(filename):
                filename = filename(self.distribution)
            self.clean_file(filename)

        remove_dirs = list(self.temporary_dirs)
        if self.all:
            remove_dirs = remove_dirs + self.nontemporary_dirs

        for dirname in remove_dirs:
            if callable(dirname):
                dirname = dirname(self.distribution)
            self.clean_dir(dirname)

        _clean.run(self)
Пример #54
0
    def run(self):
        Clean.run(self)
        if os.path.exists('build'):
            shutil.rmtree('build')
        cwd = os.path.abspath(os.path.dirname(__file__))
        for dirpath, dirnames, filenames in os.walk(cwd):
            for filename in filenames:
                if (filename.endswith('.so') or filename.endswith('.pyd')
                             or filename.endswith('.dll')
                             or filename.endswith('.pyc')
                             or filename.startswith('.DS_Store')
                             or filename.startswith('.coverage')):
                    os.unlink(os.path.join(dirpath, filename))
            for dirname in dirnames:
                if (dirname == '__pycache__' or dirname == '.pytest_cache'
                            or dirname == '.eggs'
                            or dirname.endswith('.egg-info')):
                    shutil.rmtree(os.path.join(dirpath, dirname))

        if self.all:
            if os.path.exists('.venv'):
                shutil.rmtree('.venv')
Пример #55
0
    def run(self):
        print("** cleaning python and C binaries for hstaxe **")
        current_env = sys.prefix + "/bin/"
        axe_bins = ["aXe_GOL2AF",
                    "aXe_AF2PET",
                    "aXe_BE",
                    "aXe_PET2SPC",
                    "aXe_STAMPS",
                    "aXe_DRZPREP",
                    "aXe_PETCONT",
                    "aXe_PETFF",
                    "aXe_DRZ2PET",
                    "aXe_GPS",
                    "aXe_FILET",
                    "aXe_FRIGEN",
                    "aXe_FRINGECORR",
                    "aXe_TFIT",
                    "aXe_INTPIXCORR",
                    "aXe_PETIPC",
                    "aXe_NICBACK",
                    "aXe_TEST",
                    "aXe_DIRIMAGE",
                    "aXe_SEX2GOL"
                    "aXe_SCALEBCK"]

        try:
            check_call(["make", "clean"], cwd=AXELIB_DIR)
        except CalledProcessError as e:
            print(e)
            exit(1)

        for file in axe_bins:
            myfile = current_env + file
            if os.access(myfile, os.F_OK):
                os.remove(myfile)
        if os.access(CONF_H_NAME, os.F_OK):
            os.remove(CONF_H_NAME)

        clean.run(self)
Пример #56
0
 def run(self):
     Clean.run(self)
     # Remove c files if we are not within a sdist package
     remove_c_files = not os.path.exists(os.path.join(cwd, 'PKG-INFO'))
     if remove_c_files:
         print('Will remove generated .c files')
     if os.path.exists('build'):
         shutil.rmtree('build')
     for dirpath, dirnames, filenames in os.walk(DISTNAME):
         for filename in filenames:
             if any(filename.endswith(suffix) for suffix in
                    (".so", ".pyd", ".dll", ".pyc")):
                 os.unlink(os.path.join(dirpath, filename))
                 continue
             extension = os.path.splitext(filename)[1]
             if remove_c_files and extension in ['.c', '.cpp']:
                 pyx_file = str.replace(filename, extension, '.pyx')
                 if os.path.exists(os.path.join(dirpath, pyx_file)):
                     os.unlink(os.path.join(dirpath, filename))
         for dirname in dirnames:
             if dirname == '__pycache__':
                 shutil.rmtree(os.path.join(dirpath, dirname))
Пример #57
0
    def run(self):
        distutils_clean.run(self)
        if not self.all:
            return

        # gettext byproducts
        if self.po_directory and self.po_package:
            pot = os.path.join(self.po_directory, self.po_package + ".pot")
            try:
                os.unlink(pot)
            except OSError:
                pass

        # Python byproducts
        def should_remove(filename):
            if (filename.lower()[-4:] in [".pyc", ".pyo"]
                    or filename.endswith("~")
                    or (filename.startswith("#") and filename.endswith("#"))):
                return True
            else:
                return False

        for pathname, dirs, files in os.walk("."):
            for filename in filter(should_remove, files):
                try:
                    os.unlink(os.path.join(pathname, filename))
                except EnvironmentError as err:
                    print(str(err))

        # setup.py byproducts
        for base in ["coverage", "build", "dist"]:
            if os.path.isdir(base):
                shutil.rmtree(base)

        try:
            os.remove("MANIFEST")
        except EnvironmentError:
            pass
Пример #58
0
    def run(self):
        log.info('running custom_clean')
        # Remove .pyc files
        if hasattr(os, 'walk'):
            for root, dirs, files in os.walk('.'):
                for f in files:
                    if f.endswith('.pyc'):
                        log.info("removing '%s'" % f)
                        try:
                            os.unlink(f)
                        except:
                            pass

        # Remove generated directories
        for dir in ['build', 'dist']:
            if os.path.exists(dir):
                log.info("removing '%s' (and everything under it)"%dir)
                try:
                    shutil.rmtree(dir, ignore_errors=True)
                except:
                    pass

        clean.run(self)
Пример #59
0
    def run(self):
        Clean.run(self)

        basedir = os.path.abspath(os.path.dirname(__file__))

        for relpath in ['build', '.cache', '.coverage', 'dist', 'frappe.egg-info']:
            abspath = os.path.join(basedir, relpath)
            if os.path.exists(abspath):
                if os.path.isfile(abspath):
                    os.remove(abspath)
                else:
                    shutil.rmtree(abspath)

        for dirpath, dirnames, filenames in os.walk(basedir):
            for filename in filenames:
                _, extension = os.path.splitext(filename)
                if extension in ['.pyc']:
                    abspath = os.path.join(dirpath, filename)
                    os.remove(abspath)
            for dirname in dirnames:
                if dirname in ['__pycache__']:
                    abspath = os.path.join(dirpath,  dirname)
                    shutil.rmtree(abspath)
Пример #60
0
    def run(self):
        Clean.run(self)

        cython_files = self.find(["*.pyx"])
        cythonized_files = [path.replace(".pyx", ".c") for path in cython_files]
        cythonized_files += [path.replace(".pyx", ".cpp") for path in cython_files]

        # really remove the directories
        # and not only if they are empty
        to_remove = [self.build_base]
        to_remove = self.expand(to_remove)
        to_remove += cythonized_files

        if not self.dry_run:
            for path in to_remove:
                try:
                    if os.path.isdir(path):
                        shutil.rmtree(path)
                    else:
                        os.remove(path)
                    logger.info("removing '%s'", path)
                except OSError:
                    pass