code: def get_ext_modules(pkg_name):
      pkg = __import__(pkg_name, fromlist=[""])
      pkg_dir = abspath(dirname(pkg.__file__))
      # pkg_root = __import__(pkg_name)
      ext_modules = []
      for dirpath, dirnames, filenames in os.walk(pkg_dir):
          reldir = relpath(dirpath, pkg_dir)
          if reldir == ".":
              reldir = ""
          for filename in filenames:
              froot, ext = splitext(filename)
              if ext == EXT_EXT:
                  mod_path = pjoin(reldir, froot)
                  mod_uri = pkg_name + "." + mod_path.replace(sep, ".")
                  # fromlist=[''] results in submodule being returned, rather than the
                  # top level module.  See help(__import__)
                  mod = __import__(mod_uri, fromlist=[""])
                  ext_modules.append(mod)
      return ext_modules
  
file_path: nipy/tools/doctest_extmods.py
imports: import doctest
  import os
  import sys
  from distutils.sysconfig import get_config_vars
  from optparse import OptionParser
  from os.path import abspath, dirname, relpath, sep, splitext
  from os.path import join
label_desc: Use image node_id 1 for calling a global function with example usage: get_ext_modules(pkg_name) and returns: ext_modules