Example #1
def share_files(srcdir, dstdir, interpreter, options):
    """Try to move as many files from srcdir to dstdir as possible."""
    for i in os.listdir(srcdir):
        fpath1 = join(srcdir, i)
        if not options.no_ext_rename and splitext(i)[-1] == '.so':
            # try to rename extension here as well (in :meth:`scan` info about
            # Python version is gone)
            version = interpreter.parse_public_dir(srcdir)
            # if version is True it means it's unversioned dist-packages dir
            if version and version is not True:
                # note that if ver is empty, default Python version will be used
                fpath1_orig = fpath1
                new_name = interpreter.check_extname(i, version)
                if new_name:
                    fpath1 = join(srcdir, new_name)
                    if exists(fpath1):
                        log.warn('destination file exist, '
                                 'cannot rename %s to %s', fpath1_orig, fpath1)
                        log.info('renaming %s to %s', fpath1_orig, fpath1)
                        os.renames(fpath1_orig, fpath1)
                        i = new_name
        fpath2 = join(dstdir, i)
        if not isdir(fpath1) and not exists(fpath2):
            # do not rename directories here - all .so files have to be renamed first
            os.renames(fpath1, fpath2)
        if isdir(fpath1):
            share_files(fpath1, fpath2, interpreter, options)
        elif cmpfile(fpath1, fpath2, shallow=False):
        # XXX: check symlinks

    if exists(srcdir) and not os.listdir(srcdir):