(self, egginfo_path, distinfo_path)
Convert an .egg-info directory into a .dist-info directory
Convert an .egg-info directory into a .dist-info directory
Convert an . egg - info directory into a . dist - info directory
def egg2dist(self, egginfo_path, distinfo_path):
        """Convert an .egg-info directory into a .dist-info directory"""
        def adios(p):
            """Appropriately delete directory, file or link."""
            if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p):
                shutil.rmtree(p)
            elif os.path.exists(p):
                os.unlink(p)

        adios(distinfo_path)

        if not os.path.exists(egginfo_path):
            # There is no egg-info. This is probably because the egg-info
            # file/directory is not named matching the distribution name used
            # to name the archive file. Check for this case and report
            # accordingly.
            import glob
            pat = os.path.join(os.path.dirname(egginfo_path), '*.egg-info')
            possible = glob.glob(pat)
            err = "Egg metadata expected at %s but not found" % (egginfo_path,)
            if possible:
                alt = os.path.basename(possible[0])
                err += " (%s found - possible misnamed archive file?)" % (alt,)

            raise ValueError(err)

        if os.path.isfile(egginfo_path):
            # .egg-info is a single file
            pkginfo_path = egginfo_path
            pkg_info = pkginfo_to_metadata(egginfo_path, egginfo_path)
            os.mkdir(distinfo_path)
        else:
            # .egg-info is a directory
            pkginfo_path = os.path.join(egginfo_path, 'PKG-INFO')
            pkg_info = pkginfo_to_metadata(egginfo_path, pkginfo_path)

            # ignore common egg metadata that is useless to wheel
            shutil.copytree(egginfo_path, distinfo_path,
                            ignore=lambda x, y: {'PKG-INFO', 'requires.txt', 'SOURCES.txt',
                                                 'not-zip-safe'}
                            )

            # delete dependency_links if it is only whitespace
            dependency_links_path = os.path.join(distinfo_path, 'dependency_links.txt')
            with open(dependency_links_path, 'r') as dependency_links_file:
                dependency_links = dependency_links_file.read().strip()
            if not dependency_links:
                adios(dependency_links_path)

        write_pkg_info(os.path.join(distinfo_path, 'METADATA'), pkg_info)

        for license_path in self.license_paths:
            filename = os.path.basename(license_path)
            shutil.copy(license_path, os.path.join(distinfo_path, filename))

        adios(egginfo_path)
def egg2dist ( self , egginfo_path , distinfo_path ) : def adios ( p ) : """Appropriately delete directory, file or link.""" if os . path . exists ( p ) and not os . path . islink ( p ) and os . path . isdir ( p ) : shutil . rmtree ( p ) elif os . path . exists ( p ) : os . unlink ( p ) adios ( distinfo_path ) if not os . path . exists ( egginfo_path ) : # There is no egg-info. This is probably because the egg-info # file/directory is not named matching the distribution name used # to name the archive file. Check for this case and report # accordingly. import glob pat = os . path . join ( os . path . dirname ( egginfo_path ) , '*.egg-info' ) possible = glob . glob ( pat ) err = "Egg metadata expected at %s but not found" % ( egginfo_path , ) if possible : alt = os . path . basename ( possible [ 0 ] ) err += " (%s found - possible misnamed archive file?)" % ( alt , ) raise ValueError ( err ) if os . path . isfile ( egginfo_path ) : # .egg-info is a single file pkginfo_path = egginfo_path pkg_info = pkginfo_to_metadata ( egginfo_path , egginfo_path ) os . mkdir ( distinfo_path ) else : # .egg-info is a directory pkginfo_path = os . path . join ( egginfo_path , 'PKG-INFO' ) pkg_info = pkginfo_to_metadata ( egginfo_path , pkginfo_path ) # ignore common egg metadata that is useless to wheel shutil . copytree ( egginfo_path , distinfo_path , ignore = lambda x , y : { 'PKG-INFO' , 'requires.txt' , 'SOURCES.txt' , 'not-zip-safe' } ) # delete dependency_links if it is only whitespace dependency_links_path = os . path . join ( distinfo_path , 'dependency_links.txt' ) with open ( dependency_links_path , 'r' ) as dependency_links_file : dependency_links = dependency_links_file . read ( ) . strip ( ) if not dependency_links : adios ( dependency_links_path ) write_pkg_info ( os . path . join ( distinfo_path , 'METADATA' ) , pkg_info ) for license_path in self . license_paths : filename = os . path . basename ( license_path ) shutil . copy ( license_path , os . path . join ( distinfo_path , filename ) ) adios ( egginfo_path )