def build(self, paths, tags=None, wheel_version=None):
if tags is None:<EOL><INDENT>tags = {}<EOL><DEDENT>libkey = list(filter(lambda o: o in paths, ('<STR_LIT>', '<STR_LIT>')))[<NUM_LIT:0>]<EOL>if libkey == '<STR_LIT>':<EOL><INDENT>is_pure = '<STR_LIT:false>'<EOL>default_pyver = [IMPVER]<EOL>default_abi = [ABI]<EOL>default_arch = [ARCH]<EOL><DEDENT>else:<EOL><INDENT>is_pure = '<STR_LIT:true>'<EOL>default_pyver = [PYVER]<EOL>default_abi = ['<STR_LIT:none>']<EOL>default_arch = ['<STR_LIT>']<EOL><DEDENT>self.pyver = tags.get('<STR_LIT>', default_pyver)<EOL>self.abi = tags.get('<STR_LIT>', default_abi)<EOL>self.arch = tags.get('<STR_LIT>', default_arch)<EOL>libdir = paths[libkey]<EOL>name_ver = '<STR_LIT>' % (self.name, self.version)<EOL>data_dir = '<STR_LIT>' % name_ver<EOL>info_dir = '<STR_LIT>' % name_ver<EOL>archive_paths = []<EOL>for key in ('<STR_LIT:data>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if key not in paths:<EOL><INDENT>continue<EOL><DEDENT>path = paths[key]<EOL>if os.path.isdir(path):<EOL><INDENT>for root, dirs, files in os.walk(path):<EOL><INDENT>for fn in files:<EOL><INDENT>p = fsdecode(os.path.join(root, fn))<EOL>rp = os.path.relpath(p, path)<EOL>ap = to_posix(os.path.join(data_dir, key, rp))<EOL>archive_paths.append((ap, p))<EOL>if key == '<STR_LIT>' and not p.endswith('<STR_LIT>'):<EOL><INDENT>with open(p, '<STR_LIT:rb>') as f:<EOL><INDENT>data = f.read()<EOL><DEDENT>data = self.process_shebang(data)<EOL>with open(p, '<STR_LIT:wb>') as f:<EOL><INDENT>f.write(data)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>path = libdir<EOL>distinfo = None<EOL>for root, dirs, files in os.walk(path):<EOL><INDENT>if root == path:<EOL><INDENT>for i, dn in enumerate(dirs):<EOL><INDENT>dn = fsdecode(dn)<EOL>if dn.endswith('<STR_LIT>'):<EOL><INDENT>distinfo = os.path.join(root, dn)<EOL>del dirs[i]<EOL>break<EOL><DEDENT><DEDENT>assert distinfo, '<STR_LIT>'<EOL><DEDENT>for fn in files:<EOL><INDENT>if fsdecode(fn).endswith(('<STR_LIT>', '<STR_LIT>')):<EOL><INDENT>continue<EOL><DEDENT>p = os.path.join(root, fn)<EOL>rp = to_posix(os.path.relpath(p, path))<EOL>archive_paths.append((rp, p))<EOL><DEDENT><DEDENT>files = os.listdir(distinfo)<EOL>for fn in files:<EOL><INDENT>if fn not in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>p = fsdecode(os.path.join(distinfo, fn))<EOL>ap = to_posix(os.path.join(info_dir, fn))<EOL>archive_paths.append((ap, p))<EOL><DEDENT><DEDENT>wheel_metadata = [<EOL>'<STR_LIT>' % (wheel_version or self.wheel_version),<EOL>'<STR_LIT>' % __version__,<EOL>'<STR_LIT>' % is_pure,<EOL>]<EOL>for pyver, abi, arch in self.tags:<EOL><INDENT>wheel_metadata.append('<STR_LIT>' % (pyver, abi, arch))<EOL><DEDENT>p = os.path.join(distinfo, '<STR_LIT>')<EOL>with open(p, '<STR_LIT:w>') as f:<EOL><INDENT>f.write('<STR_LIT:\n>'.join(wheel_metadata))<EOL><DEDENT>ap = to_posix(os.path.join(info_dir, '<STR_LIT>'))<EOL>archive_paths.append((ap, p))<EOL>self.write_records((distinfo, info_dir), libdir, archive_paths)<EOL>pathname = os.path.join(self.dirname, self.filename)<EOL>self.build_zip(pathname, archive_paths)<EOL>return pathname<EOL>
Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel.