def install(self, paths, maker, **kwargs):
dry_run = maker.dry_run<EOL>warner = kwargs.get('<STR_LIT>')<EOL>lib_only = kwargs.get('<STR_LIT>', False)<EOL>pathname = os.path.join(self.dirname, self.filename)<EOL>name_ver = '<STR_LIT>' % (self.name, self.version)<EOL>data_dir = '<STR_LIT>' % name_ver<EOL>info_dir = '<STR_LIT>' % name_ver<EOL>metadata_name = posixpath.join(info_dir, METADATA_FILENAME)<EOL>wheel_metadata_name = posixpath.join(info_dir, '<STR_LIT>')<EOL>record_name = posixpath.join(info_dir, '<STR_LIT>')<EOL>wrapper = codecs.getreader('<STR_LIT:utf-8>')<EOL>with ZipFile(pathname, '<STR_LIT:r>') as zf:<EOL><INDENT>with zf.open(wheel_metadata_name) as bwf:<EOL><INDENT>wf = wrapper(bwf)<EOL>message = message_from_file(wf)<EOL><DEDENT>wv = message['<STR_LIT>'].split('<STR_LIT:.>', <NUM_LIT:1>)<EOL>file_version = tuple([int(i) for i in wv])<EOL>if (file_version != self.wheel_version) and warner:<EOL><INDENT>warner(self.wheel_version, file_version)<EOL><DEDENT>if message['<STR_LIT>'] == '<STR_LIT:true>':<EOL><INDENT>libdir = paths['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>libdir = paths['<STR_LIT>']<EOL><DEDENT>records = {}<EOL>with zf.open(record_name) as bf:<EOL><INDENT>with CSVReader(stream=bf) as reader:<EOL><INDENT>for row in reader:<EOL><INDENT>p = row[<NUM_LIT:0>]<EOL>records[p] = row<EOL><DEDENT><DEDENT><DEDENT>data_pfx = posixpath.join(data_dir, '<STR_LIT>')<EOL>info_pfx = posixpath.join(info_dir, '<STR_LIT>')<EOL>script_pfx = posixpath.join(data_dir, '<STR_LIT>', '<STR_LIT>')<EOL>fileop = FileOperator(dry_run=dry_run)<EOL>fileop.record = True    <EOL>bc = not sys.dont_write_bytecode    <EOL>outfiles = []   <EOL>workdir = tempfile.mkdtemp()<EOL>maker.source_dir = workdir<EOL>maker.target_dir = None<EOL>try:<EOL><INDENT>for zinfo in zf.infolist():<EOL><INDENT>arcname = zinfo.filename<EOL>if isinstance(arcname, text_type):<EOL><INDENT>u_arcname = arcname<EOL><DEDENT>else:<EOL><INDENT>u_arcname = arcname.decode('<STR_LIT:utf-8>')<EOL><DEDENT>if u_arcname.endswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>row = records[u_arcname]<EOL>if row[<NUM_LIT:2>] and str(zinfo.file_size) != row[<NUM_LIT:2>]:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT:%s>' % u_arcname)<EOL><DEDENT>if row[<NUM_LIT:1>]:<EOL><INDENT>kind, value = row[<NUM_LIT:1>].split('<STR_LIT:=>', <NUM_LIT:1>)<EOL>with zf.open(arcname) as bf:<EOL><INDENT>data = bf.read()<EOL><DEDENT>_, digest = self.get_hash(data, kind)<EOL>if digest != value:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT:%s>' % arcname)<EOL><DEDENT><DEDENT>if lib_only and u_arcname.startswith((info_pfx, data_pfx)):<EOL><INDENT>logger.debug('<STR_LIT>', u_arcname)<EOL>continue<EOL><DEDENT>is_script = (u_arcname.startswith(script_pfx)<EOL>and not u_arcname.endswith('<STR_LIT>'))<EOL>if u_arcname.startswith(data_pfx):<EOL><INDENT>_, where, rp = u_arcname.split('<STR_LIT:/>', <NUM_LIT:2>)<EOL>outfile = os.path.join(paths[where], convert_path(rp))<EOL><DEDENT>else:<EOL><INDENT>if u_arcname in (wheel_metadata_name, record_name):<EOL><INDENT>continue<EOL><DEDENT>outfile = os.path.join(libdir, convert_path(u_arcname))<EOL><DEDENT>if not is_script:<EOL><INDENT>with zf.open(arcname) as bf:<EOL><INDENT>fileop.copy_stream(bf, outfile)<EOL><DEDENT>outfiles.append(outfile)<EOL>if not dry_run and row[<NUM_LIT:1>]:<EOL><INDENT>with open(outfile, '<STR_LIT:rb>') as bf:<EOL><INDENT>data = bf.read()<EOL>_, newdigest = self.get_hash(data, kind)<EOL>if newdigest != digest:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT:%s>' % outfile)<EOL><DEDENT><DEDENT><DEDENT>if bc and outfile.endswith('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>pyc = fileop.byte_compile(outfile)<EOL>outfiles.append(pyc)<EOL><DEDENT>except Exception:<EOL><INDENT>logger.warning('<STR_LIT>',<EOL>exc_info=True)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>fn = os.path.basename(convert_path(arcname))<EOL>workname = os.path.join(workdir, fn)<EOL>with zf.open(arcname) as bf:<EOL><INDENT>fileop.copy_stream(bf, workname)<EOL><DEDENT>dn, fn = os.path.split(outfile)<EOL>maker.target_dir = dn<EOL>filenames = maker.make(fn)<EOL>fileop.set_executable_mode(filenames)<EOL>outfiles.extend(filenames)<EOL><DEDENT><DEDENT>if lib_only:<EOL><INDENT>logger.debug('<STR_LIT>')<EOL>dist = None<EOL><DEDENT>else:<EOL><INDENT>commands = None<EOL>file_version = self.info['<STR_LIT>']<EOL>if file_version == '<STR_LIT:1.0>':<EOL><INDENT>ep = posixpath.join(info_dir, '<STR_LIT>')<EOL>try:<EOL><INDENT>with zf.open(ep) as bwf:<EOL><INDENT>epdata = read_exports(bwf)<EOL><DEDENT>commands = {}<EOL>for key in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>k = '<STR_LIT>' % key<EOL>if k in epdata:<EOL><INDENT>commands['<STR_LIT>' % key] = d = {}<EOL>for v in epdata[k].values():<EOL><INDENT>s = '<STR_LIT>' % (v.prefix, v.suffix)<EOL>if v.flags:<EOL><INDENT>s += '<STR_LIT>' % v.flags<EOL><DEDENT>d[v.name] = s<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except Exception:<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>with zf.open(metadata_name) as bwf:<EOL><INDENT>wf = wrapper(bwf)<EOL>commands = json.load(wf).get('<STR_LIT>')<EOL>if commands:<EOL><INDENT>commands = commands.get('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>except Exception:<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>if commands:<EOL><INDENT>console_scripts = commands.get('<STR_LIT>', {})<EOL>gui_scripts = commands.get('<STR_LIT>', {})<EOL>if console_scripts or gui_scripts:<EOL><INDENT>script_dir = paths.get('<STR_LIT>', '<STR_LIT>')<EOL>if not os.path.isdir(script_dir):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>maker.target_dir = script_dir<EOL>for k, v in console_scripts.items():<EOL><INDENT>script = '<STR_LIT>' % (k, v)<EOL>filenames = maker.make(script)<EOL>fileop.set_executable_mode(filenames)<EOL><DEDENT>if gui_scripts:<EOL><INDENT>options = {'<STR_LIT>': True }<EOL>for k, v in gui_scripts.items():<EOL><INDENT>script = '<STR_LIT>' % (k, v)<EOL>filenames = maker.make(script, options)<EOL>fileop.set_executable_mode(filenames)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>p = os.path.join(libdir, info_dir)<EOL>dist = InstalledDistribution(p)<EOL>paths = dict(paths)     <EOL>del paths['<STR_LIT>']<EOL>del paths['<STR_LIT>']<EOL>paths['<STR_LIT>'] = libdir<EOL>p = dist.write_shared_locations(paths, dry_run)<EOL>if p:<EOL><INDENT>outfiles.append(p)<EOL><DEDENT>dist.write_installed_files(outfiles, paths['<STR_LIT>'],<EOL>dry_run)<EOL><DEDENT>return dist<EOL><DEDENT>except Exception:  <EOL><INDENT>logger.exception('<STR_LIT>')<EOL>fileop.rollback()<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>shutil.rmtree(workdir)<EOL><DEDENT><DEDENT>
Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a discrepancy in the versions.
This can be used to issue any warnings to raise any exceptions.
If kwarg ``lib_only`` is True, only the purelib/platlib files are
installed, and the headers, scripts, data and dist-info metadata are
not written.

The return value is a :class:`InstalledDistribution` instance unless
``options.lib_only`` is True, in which case the return value is ``None``.