def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,<EOL>pycompile=True, scheme=None, isolated=False):
if not scheme:<EOL><INDENT>scheme = distutils_scheme(<EOL>name, user=user, home=home, root=root, isolated=isolated<EOL>)<EOL><DEDENT>if root_is_purelib(name, wheeldir):<EOL><INDENT>lib_dir = scheme['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>lib_dir = scheme['<STR_LIT>']<EOL><DEDENT>info_dir = []<EOL>data_dirs = []<EOL>source = wheeldir.rstrip(os.path.sep) + os.path.sep<EOL>installed = {}<EOL>changed = set()<EOL>generated = []<EOL>if pycompile:<EOL><INDENT>with captured_stdout() as stdout:<EOL><INDENT>compileall.compile_dir(source, force=True, quiet=True)<EOL><DEDENT>logger.info(remove_tracebacks(stdout.getvalue()))<EOL><DEDENT>def normpath(src, p):<EOL><INDENT>return make_path_relative(src, p).replace(os.path.sep, '<STR_LIT:/>')<EOL><DEDENT>def record_installed(srcfile, destfile, modified=False):<EOL><INDENT>"""<STR_LIT>"""<EOL>oldpath = normpath(srcfile, wheeldir)<EOL>newpath = normpath(destfile, lib_dir)<EOL>installed[oldpath] = newpath<EOL>if modified:<EOL><INDENT>changed.add(destfile)<EOL><DEDENT><DEDENT>def clobber(source, dest, is_base, fixer=None, filter=None):<EOL><INDENT>if not os.path.exists(dest):  <EOL><INDENT>os.makedirs(dest)<EOL><DEDENT>for dir, subdirs, files in os.walk(source):<EOL><INDENT>basedir = dir[len(source):].lstrip(os.path.sep)<EOL>destdir = os.path.join(dest, basedir)<EOL>if is_base and basedir.split(os.path.sep, <NUM_LIT:1>)[<NUM_LIT:0>].endswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>for s in subdirs:<EOL><INDENT>destsubdir = os.path.join(dest, basedir, s)<EOL>if is_base and basedir == '<STR_LIT>' and destsubdir.endswith('<STR_LIT>'):<EOL><INDENT>data_dirs.append(s)<EOL>continue<EOL><DEDENT>elif (is_base<EOL>and s.endswith('<STR_LIT>')<EOL>and s.lower().startswith(<EOL>req.project_name.replace('<STR_LIT:->', '<STR_LIT:_>').lower())):<EOL><INDENT>assert not info_dir, '<STR_LIT>'<EOL>info_dir.append(destsubdir)<EOL><DEDENT><DEDENT>for f in files:<EOL><INDENT>if filter and filter(f):<EOL><INDENT>continue<EOL><DEDENT>srcfile = os.path.join(dir, f)<EOL>destfile = os.path.join(dest, basedir, f)<EOL>if not os.path.exists(destdir):<EOL><INDENT>os.makedirs(destdir)<EOL><DEDENT>shutil.copyfile(srcfile, destfile)<EOL>st = os.stat(srcfile)<EOL>if hasattr(os, "<STR_LIT>"):<EOL><INDENT>os.utime(destfile, (st.st_atime, st.st_mtime))<EOL><DEDENT>if os.access(srcfile, os.X_OK):<EOL><INDENT>st = os.stat(srcfile)<EOL>permissions = (<EOL>st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH<EOL>)<EOL>os.chmod(destfile, permissions)<EOL><DEDENT>changed = False<EOL>if fixer:<EOL><INDENT>changed = fixer(destfile)<EOL><DEDENT>record_installed(srcfile, destfile, changed)<EOL><DEDENT><DEDENT><DEDENT>clobber(source, lib_dir, True)<EOL>assert info_dir, "<STR_LIT>" % req<EOL>ep_file = os.path.join(info_dir[<NUM_LIT:0>], '<STR_LIT>')<EOL>console, gui = get_entrypoints(ep_file)<EOL>def is_entrypoint_wrapper(name):<EOL><INDENT>if name.lower().endswith('<STR_LIT>'):<EOL><INDENT>matchname = name[:-<NUM_LIT:4>]<EOL><DEDENT>elif name.lower().endswith('<STR_LIT>'):<EOL><INDENT>matchname = name[:-<NUM_LIT:10>]<EOL><DEDENT>elif name.lower().endswith("<STR_LIT>"):<EOL><INDENT>matchname = name[:-<NUM_LIT:4>]<EOL><DEDENT>else:<EOL><INDENT>matchname = name<EOL><DEDENT>return (matchname in console or matchname in gui)<EOL><DEDENT>for datadir in data_dirs:<EOL><INDENT>fixer = None<EOL>filter = None<EOL>for subdir in os.listdir(os.path.join(wheeldir, datadir)):<EOL><INDENT>fixer = None<EOL>if subdir == '<STR_LIT>':<EOL><INDENT>fixer = fix_script<EOL>filter = is_entrypoint_wrapper<EOL><DEDENT>source = os.path.join(wheeldir, datadir, subdir)<EOL>dest = scheme[subdir]<EOL>clobber(source, dest, False, fixer=fixer, filter=filter)<EOL><DEDENT><DEDENT>maker = ScriptMaker(None, scheme['<STR_LIT>'])<EOL>maker.clobber = True<EOL>maker.variants = set(('<STR_LIT>', ))<EOL>maker.set_mode = True<EOL>def _get_script_text(entry):<EOL><INDENT>return maker.script_template % {<EOL>"<STR_LIT>": entry.prefix,<EOL>"<STR_LIT>": entry.suffix.split("<STR_LIT:.>")[<NUM_LIT:0>],<EOL>"<STR_LIT>": entry.suffix,<EOL>}<EOL><DEDENT>maker._get_script_text = _get_script_text<EOL>maker.script_template =
Install a wheel