docstr: Walk the list of source files in 'sources', looking for SWIG
  interface (.i) files.  Run SWIG on all that are found, and
  return a modified 'sources' list with SWIG source files replaced
  by the generated C (or C++) files.
docstr_tok: ["Walk","the","list","of","source","files","in","'sources","'",",","looking","for","SWIG","interface","(",".i",")","files",".","Run","SWIG","on","all","that","are","found",",","and","return","a","modified","'sources","'","list","with","SWIG","source","files","replaced","by","the","generated","C","(","or","C++",")","files","."]
code: def swig_sources(self, sources, extension):
      """Walk the list of source files in 'sources', looking for SWIG
      interface (.i) files.  Run SWIG on all that are found, and
      return a modified 'sources' list with SWIG source files replaced
      by the generated C (or C++) files.
      """
      new_sources = []
      swig_sources = []
      swig_targets = {}
  
      # XXX this drops generated C/C++ files into the source tree, which
      # is fine for developers who want to distribute the generated
      # source -- but there should be an option to put SWIG output in
      # the temp dir.
  
      if self.swig_cpp:
          log.warning("--swig-cpp is deprecated - use --swig-opts=-c++")
  
      if (
          self.swig_cpp
          or ("-c++" in self.swig_opts)
          or ("-c++" in extension.swig_opts)
      ):
          target_ext = ".cpp"
      else:
          target_ext = ".c"
  
      for source in sources:
          (base, ext) = os.path.splitext(source)
          if ext == ".i":  # SWIG interface file
              new_sources.append(base + "_wrap" + target_ext)
              swig_sources.append(source)
              swig_targets[source] = new_sources[-1]
          else:
              new_sources.append(source)
  
      if not swig_sources:
          return new_sources
  
      swig = self.swig or self.find_swig()
      swig_cmd = [swig, "-python"]
      swig_cmd.extend(self.swig_opts)
      if self.swig_cpp:
          swig_cmd.append("-c++")
  
      # Do not override commandline arguments
      if not self.swig_opts:
          for o in extension.swig_opts:
              swig_cmd.append(o)
  
      for source in swig_sources:
          target = swig_targets[source]
          log.info("swigging %s to %s", source, target)
          self.spawn(swig_cmd + ["-o", target, source])
  
      return new_sources
  
imports: import contextlib
  import os
  import re
  import sys
  from ..core import Command
  from ..errors import DistutilsOptionError, DistutilsSetupError, CCompilerError, DistutilsError, CompileError, DistutilsPlatformError
  from ..sysconfig import customize_compiler, get_python_version
  from ..sysconfig import get_config_h_filename
  from .._modified import newer_group
  from ..extension import Extension
  from ..util import get_platform
  from distutils._log import log
  from .None import py37compat
  from site import USER_BASE
label_desc: Use image node_id 12 for calling the build_ext obj's underlying member method code with example usage: obj.swig_sources(sources, extension) and returns: new_sources, new_sources