code: def importVersion():
      
      import imp
      try:
          # Attempt to load the template first. It only exists in a working copy cloned via git.
          import version_template
      except ImportError:
          # If loading the template fails we must be in a unpacked source distribution and
          # src/toil/version.py will already exist.
          pass
      else:
          # Use the template to generate src/toil/version.py
          import os
          import errno
          from tempfile import NamedTemporaryFile
  
          new = version_template.expand_()
          try:
              with open('src/toil/version.py') as f:
                  old = f.read()
          except IOError as e:
              if e.errno == errno.ENOENT:
                  old = None
              else:
                  raise
  
          if old != new:
              with NamedTemporaryFile(mode='w',dir='src/toil', prefix='version.py.', delete=False) as f:
                  f.write(new)
              os.rename(f.name, 'src/toil/version.py')
      # Unfortunately, we can't use a straight import here because that would also load the stuff
      # defined in src/toil/__init__.py which imports modules from external dependencies that may
      # yet to be installed when setup.py is invoked.
      return imp.load_source('toil.version', 'src/toil/version.py')
docs: Load and return the module object for src/toil/version.py, generating it from the template if
      required.