code: def generate_external(
      header=header,
      output_path=output_path,
      usedouble=False,
      overwrite=True,
  ):
      if not os.path.isdir(output_path):
          os.mkdir(output_path)
      elif not overwrite:
          return sorted(glob.glob(os.path.join(output_path, "*.c")))
  
      c_declarations = get_c_declarations(header, usedouble=usedouble)
      cpp_objects = get_cpp_objects_from_c_declarations(c_declarations)
  
      lib = generate_lib_from_c_declarations(
          cpp_objects, c_declarations
      )
      # print_c_declarations_results(lib, c_declarations)
  
      sources_list = []
      for o in lib:
          out = source_header
          mapped = MappedObject(lib[o], usedouble=usedouble)
          out += mapped.gen_code()
          output_file = os.path.join(output_path, "gen-%s.c" % o)
          with open(output_file, "w") as f:
              f.write(out)
              print("wrote %s" % output_file)
              sources_list.append(output_file)
  
      out = source_header
      out += '#include "aubio-generated.h"'
      check_types = "\n     ||  ".join(
          ["PyType_Ready(&Py_%sType) < 0" % o for o in lib]
      )
      out += """
  
  int generated_types_ready (void)
  {{
    return ({pycheck_types});
  }}
  """.format(
          pycheck_types=check_types
      )
  
      add_types = "".join(
          [
              """
    Py_INCREF (&Py_{name}Type);
    PyModule_AddObject(m, "{name}", (PyObject *) & Py_{name}Type);""".format(
                  name=o
              )
              for o in lib
          ]
      )
      out += """
  
  void add_generated_objects ( PyObject *m )
  {{
  {add_types}
  }}
  """.format(
          add_types=add_types
      )
  
      output_file = os.path.join(output_path, "aubio-generated.c")
      with open(output_file, "w") as f:
          f.write(out)
          print("wrote %s" % output_file)
          sources_list.append(output_file)
  
      objlist = "".join(
          ["extern PyTypeObject Py_%sType;\n" % p for p in lib]
      )
      out = """// generated list of objects created with gen_external.py
  
  #include <Python.h>
  """
      if usedouble:
          out += """
  #ifndef HAVE_AUBIO_DOUBLE
  #define HAVE_AUBIO_DOUBLE 1
  #endif
  """
      out += """
  {objlist}
  int generated_objects ( void );
  void add_generated_objects( PyObject *m );
  """.format(
          objlist=objlist
      )
  
      output_file = os.path.join(output_path, "aubio-generated.h")
      with open(output_file, "w") as f:
          f.write(out)
          print("wrote %s" % output_file)
          # no need to add header to list of sources
  
      return sorted(sources_list)
  
file_path: aubio/python/lib/gen_external.py
imports: import distutils.ccompiler
  import sys
  import os
  import subprocess
  import glob
  from distutils.sysconfig import customize_compiler
  from gen_code import MappedObject
label_desc: Use image node_id 9 for calling a global function with example usage: generate_external(header, output_path, usedouble, overwrite) and returns: sorted, sorted