code: def externals(trgt, **kwargs):
      
      kw = dict(
          T='svg', config=None, debug=False, display=None, exclude=[], externals=True,
          format='svg', max_bacon=2**65, no_config=True, nodot=False,
          noise_level=2**65, noshow=True, output=None, pylib=True, pylib_all=True,
          show=False, show_cycles=False, show_deps=False, show_dot=False,
          show_raw_deps=False, verbose=0, include_missing=True,
      )
      kw.update(kwargs)
      depgraph = py2depgraph.py2dep(trgt, **kw)
      pkgname = trgt.fname
      log.info("DEPGRAPH: %s", depgraph)
      pkgname = os.path.splitext(pkgname)[0]
  
      res = {}
      ext = set()
  
      for k, src in list(depgraph.sources.items()):
          if k.startswith('_'):
              continue
          if not k.startswith(pkgname):
              continue
          if src.imports:
              imps = [imp for imp in src.imports if not imp.startswith(pkgname)]
              if imps:
                  for imp in imps:
                      ext.add(imp.split('.')[0])
                  res[k] = imps
      # return res  # debug
      return list(sorted(ext))
docs: Return a list of direct external dependencies of ``pkgname``.
         Called for the ``pydeps --externals`` command.