docs: def _extract_info_from_package(dependency,
                                 extract_type=None,
                                 debug=False,
                                 include_build_requirements=False
                                 ):
      """ Internal function to extract metainfo from a package.
          Currently supported info types:
  
          - name
          - dependencies  (a list of dependencies)
      """
      output_folder = tempfile.mkdtemp(prefix="pythonpackage-metafolder-")
      try:
          extract_metainfo_files_from_package(
              dependency, output_folder, debug=debug
          )
  
          with open(os.path.join(output_folder, "METADATA"),
                    "r", encoding="utf-8"
                   ) as f:
              # Get metadata and cut away description (is after 2 linebreaks)
              metadata_entries = f.read().partition("\n\n")[0].splitlines()
  
          if extract_type == "name":
              name = None
              for meta_entry in metadata_entries:
                  if meta_entry.lower().startswith("name:"):
                      return meta_entry.partition(":")[2].strip()
              if name is None:
                  raise ValueError("failed to obtain package name")
              return name
          elif extract_type == "dependencies":
              requirements = []
              if os.path.exists(os.path.join(output_folder,
                                             'pyproject.toml')
                                ) and include_build_requirements:
                  with open(os.path.join(output_folder, 'pyproject.toml')) as f:
                      build_sys = pytoml.load(f)['build-system']
                      if "requires" in build_sys:
                          requirements += build_sys["requires"]
  
              # Add requirements from metadata:
              requirements += [
                  entry.rpartition("Requires-Dist:")[2].strip()
                  for entry in metadata_entries
                  if entry.startswith("Requires-Dist")
              ]
  
              return list(set(requirements))  # remove duplicates
      finally:
          shutil.rmtree(output_folder)