(egg_info_path, pkginfo_path)
return pkg_info
Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
Convert . egg - info directory with PKG - INFO to the Metadata 2 . 1 format
def pkginfo_to_metadata(egg_info_path, pkginfo_path):
    """
    Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
    """
    pkg_info = read_pkg_info(pkginfo_path)
    pkg_info.replace_header('Metadata-Version', '2.1')
    # Those will be regenerated from `requires.txt`.
    del pkg_info['Provides-Extra']
    del pkg_info['Requires-Dist']
    requires_path = os.path.join(egg_info_path, 'requires.txt')
    if os.path.exists(requires_path):
        with open(requires_path) as requires_file:
            requires = requires_file.read()

        parsed_requirements = sorted(pkg_resources.split_sections(requires),
                                     key=lambda x: x[0] or '')
        for extra, reqs in parsed_requirements:
            for key, value in generate_requirements({extra: reqs}):
                if (key, value) not in pkg_info.items():
                    pkg_info[key] = value

    description = pkg_info['Description']
    if description:
        pkg_info.set_payload(dedent_description(pkg_info))
        del pkg_info['Description']

    return pkg_info
def pkginfo_to_metadata ( egg_info_path , pkginfo_path ) : pkg_info = read_pkg_info ( pkginfo_path ) pkg_info . replace_header ( 'Metadata-Version' , '2.1' ) # Those will be regenerated from `requires.txt`. del pkg_info [ 'Provides-Extra' ] del pkg_info [ 'Requires-Dist' ] requires_path = os . path . join ( egg_info_path , 'requires.txt' ) if os . path . exists ( requires_path ) : with open ( requires_path ) as requires_file : requires = requires_file . read ( ) parsed_requirements = sorted ( pkg_resources . split_sections ( requires ) , key = lambda x : x [ 0 ] or '' ) for extra , reqs in parsed_requirements : for key , value in generate_requirements ( { extra : reqs } ) : if ( key , value ) not in pkg_info . items ( ) : pkg_info [ key ] = value description = pkg_info [ 'Description' ] if description : pkg_info . set_payload ( dedent_description ( pkg_info ) ) del pkg_info [ 'Description' ] return pkg_info