(self, paths, tags=None, wheel_version=None)
return pathname
Build a wheel from files in specified paths, and use any specified tags
        when determining the name of the wheel.
Build a wheel from files in specified paths, and use any specified tags
        when determining the name of the wheel.
Build a wheel from files in specified paths and use any specified tags when determining the name of the wheel .
def build(self, paths, tags=None, wheel_version=None):
        """
        Build a wheel from files in specified paths, and use any specified tags
        when determining the name of the wheel.
        """
        if tags is None:
            tags = {}

        libkey = list(filter(lambda o: o in paths, ('purelib', 'platlib')))[0]
        if libkey == 'platlib':
            is_pure = 'false'
            default_pyver = [IMPVER]
            default_abi = [ABI]
            default_arch = [ARCH]
        else:
            is_pure = 'true'
            default_pyver = [PYVER]
            default_abi = ['none']
            default_arch = ['any']

        self.pyver = tags.get('pyver', default_pyver)
        self.abi = tags.get('abi', default_abi)
        self.arch = tags.get('arch', default_arch)

        libdir = paths[libkey]

        name_ver = '%s-%s' % (self.name, self.version)
        data_dir = '%s.data' % name_ver
        info_dir = '%s.dist-info' % name_ver

        archive_paths = []

        # First, stuff which is not in site-packages
        for key in ('data', 'headers', 'scripts'):
            if key not in paths:
                continue
            path = paths[key]
            if os.path.isdir(path):
                for root, dirs, files in os.walk(path):
                    for fn in files:
                        p = fsdecode(os.path.join(root, fn))
                        rp = os.path.relpath(p, path)
                        ap = to_posix(os.path.join(data_dir, key, rp))
                        archive_paths.append((ap, p))
                        if key == 'scripts' and not p.endswith('.exe'):
                            with open(p, 'rb') as f:
                                data = f.read()
                            data = self.process_shebang(data)
                            with open(p, 'wb') as f:
                                f.write(data)

        # Now, stuff which is in site-packages, other than the
        # distinfo stuff.
        path = libdir
        distinfo = None
        for root, dirs, files in os.walk(path):
            if root == path:
                # At the top level only, save distinfo for later
                # and skip it for now
                for i, dn in enumerate(dirs):
                    dn = fsdecode(dn)
                    if dn.endswith('.dist-info'):
                        distinfo = os.path.join(root, dn)
                        del dirs[i]
                        break
                assert distinfo, '.dist-info directory expected, not found'

            for fn in files:
                # comment out next suite to leave .pyc files in
                if fsdecode(fn).endswith(('.pyc', '.pyo')):
                    continue
                p = os.path.join(root, fn)
                rp = to_posix(os.path.relpath(p, path))
                archive_paths.append((rp, p))

        # Now distinfo. Assumed to be flat, i.e. os.listdir is enough.
        files = os.listdir(distinfo)
        for fn in files:
            if fn not in ('RECORD', 'INSTALLER', 'SHARED', 'WHEEL'):
                p = fsdecode(os.path.join(distinfo, fn))
                ap = to_posix(os.path.join(info_dir, fn))
                archive_paths.append((ap, p))

        wheel_metadata = [
            'Wheel-Version: %d.%d' % (wheel_version or self.wheel_version),
            'Generator: distlib %s' % __version__,
            'Root-Is-Purelib: %s' % is_pure,
        ]
        for pyver, abi, arch in self.tags:
            wheel_metadata.append('Tag: %s-%s-%s' % (pyver, abi, arch))
        p = os.path.join(distinfo, 'WHEEL')
        with open(p, 'w') as f:
            f.write('\n'.join(wheel_metadata))
        ap = to_posix(os.path.join(info_dir, 'WHEEL'))
        archive_paths.append((ap, p))

        # Now, at last, RECORD.
        # Paths in here are archive paths - nothing else makes sense.
        self.write_records((distinfo, info_dir), libdir, archive_paths)
        # Now, ready to build the zip file
        pathname = os.path.join(self.dirname, self.filename)
        self.build_zip(pathname, archive_paths)
        return pathname
def build ( self , paths , tags = None , wheel_version = None ) : if tags is None : tags = { } libkey = list ( filter ( lambda o : o in paths , ( 'purelib' , 'platlib' ) ) ) [ 0 ] if libkey == 'platlib' : is_pure = 'false' default_pyver = [ IMPVER ] default_abi = [ ABI ] default_arch = [ ARCH ] else : is_pure = 'true' default_pyver = [ PYVER ] default_abi = [ 'none' ] default_arch = [ 'any' ] self . pyver = tags . get ( 'pyver' , default_pyver ) self . abi = tags . get ( 'abi' , default_abi ) self . arch = tags . get ( 'arch' , default_arch ) libdir = paths [ libkey ] name_ver = '%s-%s' % ( self . name , self . version ) data_dir = '%s.data' % name_ver info_dir = '%s.dist-info' % name_ver archive_paths = [ ] # First, stuff which is not in site-packages for key in ( 'data' , 'headers' , 'scripts' ) : if key not in paths : continue path = paths [ key ] if os . path . isdir ( path ) : for root , dirs , files in os . walk ( path ) : for fn in files : p = fsdecode ( os . path . join ( root , fn ) ) rp = os . path . relpath ( p , path ) ap = to_posix ( os . path . join ( data_dir , key , rp ) ) archive_paths . append ( ( ap , p ) ) if key == 'scripts' and not p . endswith ( '.exe' ) : with open ( p , 'rb' ) as f : data = f . read ( ) data = self . process_shebang ( data ) with open ( p , 'wb' ) as f : f . write ( data ) # Now, stuff which is in site-packages, other than the # distinfo stuff. path = libdir distinfo = None for root , dirs , files in os . walk ( path ) : if root == path : # At the top level only, save distinfo for later # and skip it for now for i , dn in enumerate ( dirs ) : dn = fsdecode ( dn ) if dn . endswith ( '.dist-info' ) : distinfo = os . path . join ( root , dn ) del dirs [ i ] break assert distinfo , '.dist-info directory expected, not found' for fn in files : # comment out next suite to leave .pyc files in if fsdecode ( fn ) . endswith ( ( '.pyc' , '.pyo' ) ) : continue p = os . path . join ( root , fn ) rp = to_posix ( os . path . relpath ( p , path ) ) archive_paths . append ( ( rp , p ) ) # Now distinfo. Assumed to be flat, i.e. os.listdir is enough. files = os . listdir ( distinfo ) for fn in files : if fn not in ( 'RECORD' , 'INSTALLER' , 'SHARED' , 'WHEEL' ) : p = fsdecode ( os . path . join ( distinfo , fn ) ) ap = to_posix ( os . path . join ( info_dir , fn ) ) archive_paths . append ( ( ap , p ) ) wheel_metadata = [ 'Wheel-Version: %d.%d' % ( wheel_version or self . wheel_version ) , 'Generator: distlib %s' % __version__ , 'Root-Is-Purelib: %s' % is_pure , ] for pyver , abi , arch in self . tags : wheel_metadata . append ( 'Tag: %s-%s-%s' % ( pyver , abi , arch ) ) p = os . path . join ( distinfo , 'WHEEL' ) with open ( p , 'w' ) as f : f . write ( '\n' . join ( wheel_metadata ) ) ap = to_posix ( os . path . join ( info_dir , 'WHEEL' ) ) archive_paths . append ( ( ap , p ) ) # Now, at last, RECORD. # Paths in here are archive paths - nothing else makes sense. self . write_records ( ( distinfo , info_dir ) , libdir , archive_paths ) # Now, ready to build the zip file pathname = os . path . join ( self . dirname , self . filename ) self . build_zip ( pathname , archive_paths ) return pathname