code: def add_packages(packages, ext=None, **kw):
      """use pkg-config to search which of 'packages' are installed"""
      flag_map = {
          "-I": "include_dirs",
          "-L": "library_dirs",
          "-l": "libraries",
      }
  
      # if a setuptools extension is passed, fill it with pkg-config results
      if ext:
          kw = {
              "include_dirs": ext.include_dirs,
              "extra_link_args": ext.extra_link_args,
              "library_dirs": ext.library_dirs,
              "libraries": ext.libraries,
          }
  
      for package in packages:
          print("checking for {:s}".format(package))
          cmd = ["pkg-config", "--libs", "--cflags", package]
          try:
              tokens = subprocess.check_output(cmd)
          except Exception as e:
              print(
                  'Running "{:s}" failed: {:s}'.format(
                      " ".join(cmd), repr(e)
                  )
              )
              continue
          tokens = tokens.decode("utf8").split()
          for token in tokens:
              key = token[:2]
              try:
                  arg = flag_map[key]
                  value = token[2:]
              except KeyError:
                  arg = "extra_link_args"
                  value = token
              kw.setdefault(arg, []).append(value)
      for key, value in iter(kw.items()):  # remove duplicated
          kw[key] = list(set(value))
      return kw
  
imports: import sys, os, glob, subprocess
  import distutils, distutils.command.clean, distutils.dir_util
  from gen_external import generate_external, header, output_path
  from this_version import get_aubio_version
  from distutils.command.build_ext import build_ext
label_desc: Use image node_id 1 for calling a global function with example usage: add_packages(packages, ext) and returns: kw