Пример #1
0
 def run (self):
     old_data.run(self)
     mkdir(self.data_install_dir)
     if (not hasattr(self.distribution, 'using_py2exe') or \
             not self.distribution.using_py2exe) and self.data_dirs:
         for tpl in self.data_dirs:
             target = os.path.join(self.data_install_dir, tpl[0])
             for d in tpl[1]:
                 copy_tree(d, target, excludes=['.svn*', 'CVS*',
                                                'Makefile*'])
Пример #2
0
    def run(self):
        if not self.web_ext_modules:
            return

        ## Make sure that extension sources are complete.
        self.run_command('build_src')
        build = self.get_finalized_command('build')
        environ = self.distribution.environment

        for wext in self.web_ext_modules:
            if self.distribution.verbose:
                print('building web extension "' + \
                    os.path.join(wext.public_subdir, wext.name) + '" sources')

            target = os.path.abspath(os.path.join(options.target_build_dir,
                                                  'http', wext.public_subdir))
            mkdir(target)
            here = os.getcwd()
            src_dir = os.path.abspath(wext.source_directory)
            working_dir = os.path.abspath(os.path.join(build.build_temp,
                                                       'web', wext.name))
            mkdir(working_dir)

            for support in wext.extra_support_files:
                src_file = os.path.join(CLIENT_SUPPORT_DIR, support + '.in')
                if not os.path.exists(src_file):
                    src_file = src_file[:-3]
                dst_file = os.path.join(working_dir, support)
                configure_file(environ, src_file, dst_file)

            reprocess = True
            ref = os.path.join(target, wext.name + '.html')
            if os.path.exists(ref) and not self.force:
                reprocess = False
                for src in wext.sources:
                    if os.path.getmtime(ref) < os.path.getmtime(src):
                        reprocess = True
            if reprocess:
                ## Special handling for 'public' directory
                configure_files(environ, os.path.join(src_dir, 'public'),
                                '*', os.path.join(working_dir, 'public'),
                                excludes=['.svn', 'CVS'])

                if len(wext.sources) > 0:
                    for s in wext.sources:
                        configure_file(environ, s,
                                       os.path.join(working_dir,
                                                    os.path.basename(s)))
                    #import pyjs  # pylint: disable=F0401,W0611,W0612
                    ## TODO: use pyjs module directly (instead of 'pyjsbuild')
                    try:
                        compiler = environ['PYJSBUILD']
                    except KeyError:
                        compiler = self.pyjscompiler
                    if compiler is None:
                        env = configure_package('pyjamas')
                        compiler = env['PYJSBUILD']
                        if compiler is None:
                            raise DistutilsExecError("no pyjsbuild executable found or given")
                    cmd_line = [os.path.abspath(compiler)]
                    for arg in wext.extra_compile_args:
                        if 'debug' in arg.lower():
                            cmd_line.append('--debug')
                            cmd_line.append('--print-statements')
                        else:
                            cmd_line.append(arg)
                    if self.distribution.verbose:
                        cmd_line.append('--log-level=' + str(logging.INFO))
                    else:
                        cmd_line.append('--log-level=' + str(logging.ERROR))
                    cmd_line.append('--output=' + target)
                    cmd_line.append(wext.name)

                    os.chdir(working_dir)
                    status = subprocess.call(cmd_line)
                    if status != 0:
                        raise Exception("Command '" + str(cmd_line) +
                                        "' returned non-zero exit status "
                                        + str(status))
                    os.chdir(here)

            pubdir = os.path.join(working_dir, 'public')
            excludes = ['.svn', 'CVS']
            if len(wext.sources) < 1:  ## PYJS did not run
                copy_tree(pubdir, target, excludes=excludes,
                          verbose=self.distribution.verbose)

            for filename in wext.extra_public_files:
                filepath = os.path.join(CLIENT_SUPPORT_DIR, filename + '.in')
                if not os.path.exists(filepath):
                    filepath = filepath[:-3]
                targetfile = os.path.join(target, filename)
                if '.js' in filename:
                    targetfile = os.path.join(target,
                                              options.javascript_dir, filename)
                if '.css' in filename:
                    targetfile = os.path.join(target,
                                              options.stylesheet_dir, filename)
                if not os.path.exists(targetfile):
                    configure_file(environ, filepath, targetfile)

            ## Copy over downloaded files
            js_dir = os.path.join(options.target_build_dir,
                                  options.javascript_dir)
            if os.path.exists(js_dir):
                copy_tree(js_dir, os.path.join(target, options.javascript_dir))
            css_dir = os.path.join(options.target_build_dir,
                                   options.stylesheet_dir)
            if os.path.exists(css_dir):
                copy_tree(css_dir, os.path.join(target, options.stylesheet_dir))
            php_dir = os.path.join(options.target_build_dir, options.script_dir)
            if os.path.exists(php_dir):
                copy_tree(php_dir, target)

            ## pyjs processing ignores hidden files in public
            hidden = []
            for root, _, filenames in os.walk(pubdir):
                for ex in excludes:
                    if fnmatch.fnmatch(root, ex):
                        continue
                for filename in fnmatch.filter(filenames, ".??*"):
                    hidden.append(os.path.join(root[len(pubdir)+1:], filename))
            for filepath in hidden:
                targetfile = os.path.join(target, filepath)
                if not os.path.exists(targetfile):
                    shutil.copyfile(os.path.join(pubdir, filepath), targetfile)

            stat_info = os.stat(os.path.join(src_dir, 'public'))
            uid = stat_info.st_uid
            gid = stat_info.st_gid
            recursive_chown(target, uid, gid)

            if not os.path.lexists(os.path.join(target, 'index.html')) and \
                    os.path.lexists(os.path.join(target, wext.name + '.html')):
                shutil.copyfile(os.path.join(target, wext.name + '.html'),
                                os.path.join(target, 'index.html'))
            if not os.path.lexists(os.path.join(target, 'index.php')) and \
                    os.path.lexists(os.path.join(target, wext.name + '.php')):
                shutil.copyfile(os.path.join(target, wext.name + '.php'),
                                os.path.join(target, 'index.php'))
Пример #3
0
def make_doc(src_file, target_dir=None, stylesheet=None):
    (XSLTPROC, JAVA_SAXON, NET_SAXON) = range(3)

    src_dir = os.path.abspath(os.path.dirname(src_file))
    if target_dir is None:
        pth = os.path.relpath(os.path.dirname(src_file)).split(os.sep)[1:]
        # pylint: disable=W0142
        target_dir = os.path.join(options.target_build_dir, *pth)
    if stylesheet is None:
        stylesheet = 'http://docbook.sourceforge.net/release/fo/docbook.xsl'

    fop_exe = find_program('fop')
    java_exe = find_program('java')
    try:  ## prefer xsltproc
        xslt_exe = [find_program('xsltproc')]
        which = XSLTPROC
    except Exception:  # pylint: disable=W0703
        try:
            classpaths = []
            try:
                for path in os.environ['CLASSPATH'].split(os.pathsep):
                    classpaths.append(os.path.dirname(path))
            except KeyError:
                pass
            try:
                classpaths.append(os.path.join(os.environ['JAVA_HOME'], 'lib'))
            except KeyError:
                pass
            saxon_jar = find_file('saxon*.jar',
                                  ['/usr/share/java', '/usr/local/share/java',
                                   '/opt/local/share/java',] + classpaths)
            resolver_jar = find_file('resolver*.jar',
                                     ['/usr/share/java',
                                      '/usr/local/share/java',
                                      '/opt/local/share/java',] + classpaths)
            xslt_exe = [java_exe, '-classpath',
                        os.pathsep.join([saxon_jar, resolver_jar]),
                        '-jar', saxon_jar]
            which = JAVA_SAXON
        except Exception:  # pylint: disable=W0703
            xslt_exe = [find_program('saxon')]
            which = NET_SAXON

    if not os.path.exists(target_dir):
        mkdir(target_dir)
    copy_tree(src_dir, target_dir)

    ## Need to respect relative paths
    here = os.getcwd()
    os.chdir(target_dir)
    src_base = os.path.basename(src_file)
    fo_src = os.path.splitext(src_base)[0] + '.fo'
    pdf_dst = os.path.splitext(src_base)[0] + '.pdf'

    if which == XSLTPROC:
        cmd_line = xslt_exe + ['-xinclude', '-o', fo_src, stylesheet, src_base]
    elif which == JAVA_SAXON:
        cmd_line = xslt_exe + ['-o', fo_src, src_base, stylesheet]
    else:
        cmd_line = xslt_exe + [src_base, '-o:' + fo_src, '-xsl:' + stylesheet]
        if 'XML_CATALOG_FILES' in os.environ:
            cmd_line += ['-catalog:' + os.environ['XML_CATALOG_FILES']]
    subprocess.check_call(" ".join(cmd_line), shell=True)

    cmd_line = [fop_exe, '-fo', fo_src, '-pdf', pdf_dst]
    subprocess.check_call(" ".join(cmd_line), shell=True)
    os.chdir(here)
Пример #4
0
    def run(self):
        if not self.distribution.doc_modules:
            return

        ## Make sure that sources are complete in build_lib.
        self.run_command('build_src')
        ## Ditto extensions
        self.run_command('build_ext')

        build = self.get_finalized_command('build')
        buildpy = self.get_finalized_command('build_py')
        ## packages and files are in build.build_lib (see build_py.py)
        target = os.path.join(os.path.abspath(build.build_base), 'http')
        mkdir(target)
        build_verbose = self.distribution.verbose
        environ = self.distribution.environment

        for dext in self.distribution.doc_modules:
            if self.distribution.verbose:
                print('building documentation "' + dext.name + '" sources')

            doc_dir = os.path.abspath(dext.source_directory)
            extra_dirs = dext.extra_directories
            src_dir = os.path.abspath(dext.name)
            here = os.getcwd()

            reprocess = True
            ref = os.path.join(target, dext.name + '.html')
            root_dir = dext.name
            if os.path.exists(ref) and not self.force:
                reprocess = False
                for root, _, filenames in os.walk(src_dir):
                    for fn in fnmatch.filter(filenames, '*.rst'):
                        doc = os.path.join(root, fn)
                        if os.path.getmtime(ref) < os.path.getmtime(doc):
                            reprocess = True
                            break
                        src = os.path.join(root_dir, root[len(doc_dir)+1:],
                                            fn[:-3] + 'py')
                        if os.path.exists(src):
                            if os.path.getmtime(ref) < os.path.getmtime(src):
                                reprocess = True
                                break
            if reprocess:
                working_dir = os.path.abspath(build.build_lib)
                for package in buildpy.packages:
                    pkgdir = buildpy.get_package_dir(package)
                    pkgsrcdir = os.path.join(os.path.dirname(src_dir), pkgdir)
                    configure_files(environ, pkgsrcdir,
                                    '*.rst', os.path.join(working_dir, pkgdir))

                cfg_dir = os.path.join(working_dir, dext.source_directory)
                environ['BUILD_DIR'] = working_dir

                copy_tree(doc_dir, working_dir, True,
                          excludes=[dext.name, '.svn', 'CVS', '.git', '.hg*'])
                copy_tree(os.path.join(doc_dir, dext.name),
                          os.path.join(cfg_dir, dext.name), True,
                          excludes=['.svn', 'CVS', '.git', '.hg*'])
                for d in extra_dirs:
                    subdir = os.path.basename(os.path.normpath(d))
                    copy_tree(d, os.path.join(target, subdir), True,
                              excludes=['.svn', 'CVS', '.git', '.hg*'])

                if os.path.exists(os.path.join(doc_dir, dext.doxygen_cfg)):
                    ## Doxygen + breathe
                    print('Config ' + os.path.join(doc_dir, dext.doxygen_cfg))
                    configure_file(environ,
                                   os.path.join(doc_dir, dext.doxygen_cfg),
                                   os.path.join(working_dir, dext.doxygen_cfg),
                                   style=dext.style)
                    for s in dext.doxygen_srcs:
                        configure_file(environ,
                                       os.path.join(doc_dir, s),
                                       os.path.join(working_dir, s),
                                       style=dext.style)
                    try:
                        doxygen_exe = find_program('doxygen')
                    except Exception:  # pylint: disable=W0703
                        sys.stderr.write('ERROR: Doxygen not installed ' +
                                         '(required for documentation).\n')
                        return

                    reprocess = True
                    ref = os.path.join(working_dir, 'html', 'index.html')
                    if os.path.exists(ref) and not self.force:
                        reprocess = False
                        for d in environ['C_SOURCE_DIRS'].split(' '):
                            for orig in glob.glob(os.path.join(d, '*.h*')):
                                if os.path.getmtime(ref) < \
                                   os.path.getmtime(orig):
                                    reprocess = True
                                    break
                    if reprocess:
                        if self.distribution.verbose:
                            out = sys.stdout
                            err = sys.stderr
                        else:
                            out = err = open('doxygen.log', 'w')
                        os.chdir(working_dir)
                        cmd_line = [doxygen_exe, dext.doxygen_cfg]
                        status = subprocess.call(cmd_line,
                                                 stdout=out, stderr=err)
                        if status != 0:
                            raise Exception("Command '" + str(cmd_line) +
                                            "' returned non-zero exit status "
                                            + str(status))

                        if not self.distribution.verbose:
                            out.close()
                        copy_tree('html', os.path.join(target, 'html'), True,
                                  excludes=['.svn', 'CVS', '.git', '.hg*'])
                        copy_tree('xml', os.path.join(cfg_dir, 'xml'), True)
                        os.chdir(here)
                        create_breathe_stylesheet(target)

                for f in dext.extra_docs:
                    shutil.copy(os.path.join(doc_dir, f), target)

                ## Sphinx
                if dext.without_sphinx:
                    return
                if dext.sphinx_config is None:
                    level_up = os.path.dirname(os.path.dirname(__file__))
                    dext.sphinx_config = os.path.join(level_up,
                                                      'sphinx_conf.py.in')
                elif os.path.dirname(dext.sphinx_config) == '':
                    dext.sphinx_config =  os.path.join(doc_dir,
                                                       dext.sphinx_config)
                configure_file(environ, dext.sphinx_config,
                               os.path.join(cfg_dir, 'conf.py'))
                import warnings
                try:
                    import sphinx  # pylint: disable=W0612
                except ImportError:
                    configure_package('breathe')  ## requires sphinx
                    sys.path.insert(0, os.path.join(options.target_build_dir,
                                                    options.local_lib_dir))

                from sphinx.application import Sphinx
                if 'windows' in platform.system().lower() or \
                   not build_verbose:
                    from sphinx.util.console import nocolor
                warnings.filterwarnings("ignore",
                                        category=PendingDeprecationWarning)
                warnings.filterwarnings("ignore", category=UserWarning)

                status = sys.stdout
                if not build_verbose:
                    status = open('sphinx.log', 'w')
                if 'windows' in platform.system().lower() or not build_verbose:
                    nocolor()
                try:
                    ## args: srcdir, confdir, outdir, doctreedir, buildername
                    sphinx_app = Sphinx(os.path.join(working_dir, dext.name),
                                        cfg_dir, target,
                                        os.path.join(target, '.doctrees'),
                                        'html', status=status)
                    sphinx_app.build(force_all=True, filenames=None)
                except Exception:  # pylint: disable=W0703
                    if build_verbose:
                        print('ERROR: ' + str(sys.exc_info()[1]))
                    else:
                        pass
                if not build_verbose:
                    status.close()
                warnings.resetwarnings()
Пример #5
0
    def run(self):
        failed = False
        build = self.get_finalized_command('build')
        if self.sublevel == 0 and not build.ran:
            self.run_command('build')

        if self.distribution.subpackages != None:
            subs = []
            for (pkg_name, pkg_dir) in self.distribution.subpackages:
                rf = RequirementsFinder(os.path.join(pkg_dir, 'setup.py'))
                if rf.is_sysdevel_build:
                    subs.append((pkg_name, pkg_dir))
            idx = 0
            for i in range(len(sys.argv)):
                idx = i
                if 'setup.py' in sys.argv[idx]:
                    break
            argv = list(sys.argv[idx+1:])
            for arg in sys.argv:
                if arg == 'clean' or '--sublevel' in arg:
                    argv.remove(arg)

            argv += ['--sublevel=' + str(self.sublevel + 1)]
            failed = process_subpackages(build.distribution.parallel_build,
                                         'test',
                                         os.path.abspath(build.build_base),
                                         subs, argv, False)

        ## PYTHON
        if self._has_python_tests():
            self.run_command('build')
            build = self.get_finalized_command('build')
            build_dir = os.path.abspath(build.build_base)
            environ = self.distribution.environment

            pkg_dirs = [build_dir, os.path.abspath(build.build_lib),
                        os.path.join(build_dir, 'python')]
            lib_dirs = [os.path.abspath(build.build_temp)]
            try:
                lib_dirs += environ['PATH']  ## need dlls for windows
            except KeyError:
                pass
            try:
                lib_dirs.append(os.path.join(environ['MINGW_DIR'], 'bin'))
                lib_dirs.append(os.path.join(environ['MSYS_DIR'], 'bin'))
                lib_dirs.append(os.path.join(environ['MSYS_DIR'], 'lib'))
            except KeyError:
                pass
            #postfix = '.'.join(build.build_temp.split('.')[1:])        

            for pkg, units in self._get_python_tests():
                test_dir = os.path.join(build_dir, 'test_' + pkg)
                if not os.path.exists(test_dir):
                    copy_tree('test', test_dir, excludes=['.svn*', 'CVS*'])
                f = open(os.path.join(test_dir, '__init__.py'), 'w')
                f.write("__all__ = ['" +
                        "', '".join(units) + "']\n")
                f.close()
                outfile = os.path.join(build_dir, 'test_' + pkg + '.py')
                create_testscript('test_' + pkg, units, outfile, pkg_dirs)
                wrap = create_test_wrapper(outfile, build_dir, lib_dirs)
                log.info('Python unit tests for ' + pkg)
                try:
                    check_call([wrap])
                except subprocess.CalledProcessError:
                    failed = True
                    print(sys.exc_info()[1])

        ## FORTRAN
        if self._has_fortran_tests():
            env = configure_package('fruit')
            fortran_unittest_framework = [
                os.path.join(env['FRUIT_SOURCE_DIR'], src)
                for src in env['FRUIT_SOURCE_FILES']]
            orig_exes = self.distribution.native_executables

            build = self.get_finalized_command('build')
            lib_dir = os.path.abspath(build.build_temp)
            for pkg, units in self._get_fortran_tests():
                for unit in units:
                    unit.sources = fortran_unittest_framework + unit.sources + \
                        create_fruit_driver(unit.name, unit.sources[0])
                    unit.library_dirs.append(lib_dir)
                    self.distribution.native_executables.append(unit)

            ## build w/ distutils thru backdoor
            cmd_obj = self.get_command_obj('build_exe')
            cmd_obj.ensure_finalized()
            cmd_obj.run()
            self.distribution.native_executables = orig_exes

            for pkg, units in self._get_fortran_tests():
                log.info('Fortran unit tests for ' + pkg)
                for unit in units:
                    try:
                        check_call([os.path.join(lib_dir, unit.name)])
                    except subprocess.CalledProcessError:
                        failed = True
                        print(sys.exc_info()[1])

        ## C
        if self._has_c_tests():
            env = configure_package('cunit')
            orig_exes = self.distribution.native_executables

            build = self.get_finalized_command('build')
            lib_dir = os.path.abspath(build.build_temp)
            for pkg, units in self._get_c_tests():
                for unit in units:
                    unit.sources += create_cunit_driver(unit.name,
                                                             unit.sources[0])
                    unit.include_dirs.append(env['CUNIT_INCLUDE_DIR'])
                    unit.libraries.append(env['CUNIT_LIBRARIES'])
                    unit.library_dirs.append(env['CUNIT_LIB_DIR'])
                    self.distribution.native_executables.append(unit)

            ## build w/ distutils thru backdoor
            cmd_obj = self.get_command_obj('build_exe')
            cmd_obj.ensure_finalized()
            cmd_obj.run()
            self.distribution.native_executables = orig_exes

            for pkg, units in self._get_c_tests():
                log.info('C unit tests for ' + pkg)
                for unit in units:
                    try:
                        check_call([os.path.join(lib_dir, unit.name)])
                    except subprocess.CalledProcessError:
                        failed = True
                        print(sys.exc_info()[1])

        ## C++
        if self._has_cpp_tests():
            env = configure_package('cppunit')
            orig_exes = self.distribution.native_executables

            build = self.get_finalized_command('build')
            lib_dir = os.path.abspath(build.build_temp)
            for pkg, units in self._get_cpp_tests():
                for unit in units:
                    unit.sources += create_cppunit_driver(unit.name)
                    unit.include_dirs.append(env['CPPUNIT_INCLUDE_DIR'])
                    unit.libraries.append(env['CPPUNIT_LIBRARIES'])
                    unit.library_dirs.append(env['CPPUNIT_LIB_DIR'])
                    self.distribution.native_executables.append(unit)

            ## build w/ distutils thru backdoor
            cmd_obj = self.get_command_obj('build_exe')
            cmd_obj.ensure_finalized()
            cmd_obj.run()
            self.distribution.native_executables = orig_exes

            for pkg, units in self._get_cpp_tests():
                log.info('C++ unit tests for ' + pkg)
                for unit in units:
                    try:
                        check_call([os.path.join(lib_dir, unit.name)])
                    except subprocess.CalledProcessError:
                        failed = True
                        print(sys.exc_info()[1])

        ## Javascript
        if self._has_js_tests():
            env = configure_package('qunitsuite')
            from qunitsuite.suite import QUnitSuite  \
                # pylint: disable=F0401,E0602
            for pkg, units in self._get_js_tests():
                for unit in units:
                    suite = QUnitSuite(unit)
                    result = unittest.TextTestRunner(verbosity=2).run(suite)
                    if len(result.errors) > 0:
                        failed = True
                        for error in result.errors:
                            print(error[1])
                    if len(result.failures) > 0:
                        failed = True
                        for failure in result.failures:
                            print(failure[1])

        if failed:
            sys.exit(1)
Пример #6
0
def make_doc(src_file, target_dir=None, mode='docbook'):
    if target_dir is None:
        pth = os.path.relpath(os.path.dirname(src_file)).split(os.sep)[1:]
        # pylint: disable=W0142
        target_dir = os.path.join(options.target_build_dir, *pth)

    emacs_exe = find_program('emacs')
    src_dir = os.path.abspath(os.path.dirname(src_file))
    mkdir(target_dir)
    copy_tree(src_dir, target_dir)
    cfg_filename = os.path.join(target_dir, '.emacs')
    cfg = open(cfg_filename, 'w')
    cfg.write("(require 'org-latex)\n" +
              "(unless (boundp 'org-export-latex-classes)\n" +
              "  (setq org-export-latex-classes nil))\n" +
              "(add-to-list 'org-export-latex-classes\n" +
              "             '(\"short-book\"\n" +
              "               \"\\\\documentclass{book}\"\n" +
              "               (\"\\\\chapter{%s}\" . \"\\\\chapter*{%s}\")\n" +
              "               (\"\\\\section{%s}\" . \"\\\\section*{%s}\")\n" +
              "               (\"\\\\subsection{%s}\" . \"\\\\subsection*{%s}\")\n" +
              "               (\"\\\\subsubsection{%s}\" . \"\\\\subsubsection*{%s}\"))\n" +
              "             )\n"
          )
    cfg.close()

    ## Check version of org-mode
    cmd_line = [emacs_exe, '--batch', "--execute='(message (org-version))'"]
    p = subprocess.Popen(" ".join(cmd_line), shell=True,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    _, err = p.communicate()
    version_eight = False
    try:
        last = err.split('\n')[-2]
        if int(last[:last.index('.')]) > 7:
            version_eight = True
    except:
        raise Exception("Emacs does not have Org mode support.")

    ## Emacs Org mode export
    cmd_line = [emacs_exe, '--batch',
                "--execute='(load-file \"" + cfg_filename + "\"))'",
                '--visit=' + src_file]
    base_filename = os.path.splitext(os.path.basename(src_file))[0]
    if 'pdflatex' in mode:
        cmd_line.append("--execute='(org-export-as-pdf nil)'")
        result_files = [base_filename + '.tex', base_filename + '.pdf',]
    elif 'latex' in mode:
        cmd_line.append("--execute='(org-export-as-latex nil)'")
        result_files = [base_filename + '.tex']
    elif 'html' in mode:
        cmd_line.append("--execute='(org-export-as-html nil)'")
        result_files = [base_filename + '.html']
    else:
        if version_eight:
            ## TODO  texinfo for org v8.0+
            raise Exception("Emacs Org mode v8.0+ is not (yet) supported")
        else:
            cmd_line.append("--execute='(org-export-as-docbook nil)'")
            result_files = [base_filename + '.xml']

    subprocess.check_call(" ".join(cmd_line), shell=True)
    os.remove(cfg_filename)

    for r in result_files:
        shutil.move(os.path.join(src_dir, r),
                    os.path.join(target_dir, r))
    return os.path.join(target_dir, result_files[-1])