code: def pkginfo_to_metadata(egg_info_path, pkginfo_path):
      
      pkg_info = read_pkg_info(pkginfo_path)
      pkg_info.replace_header('Metadata-Version', '2.1')
      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()
          for extra, reqs in sorted(pkg_resources.split_sections(requires),
                                    key=lambda x: x[0] or ''):
              for item in generate_requirements({extra: reqs}):
                  pkg_info[item[0]] = item[1]
  
      description = pkg_info['Description']
      if description:
          pkg_info.set_payload(dedent_description(pkg_info))
          del pkg_info['Description']
  
      return pkg_info
docs: Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format