code: def extract_version(exepath, version_arg, word_index=-1, version_rank=3):
      
      if isinstance(version_arg, basestring):
          version_arg = [version_arg]
      args = [exepath] + version_arg
  
      stdout, stderr, returncode = _run_command(args)
      if returncode:
          raise RezBindError("failed to execute %s: %s\n(error code %d)"
                             % (exepath, stderr, returncode))
  
      stdout = stdout.strip().split('\n')[0].strip()
      log("extracting version from output: '%s'" % stdout)
  
      try:
          strver = stdout.split()[word_index]
          toks = strver.replace('.', ' ').replace('-', ' ').split()
          strver = '.'.join(toks[:version_rank])
          version = Version(strver)
      except Exception as e:
          raise RezBindError("failed to parse version from output '%s': %s"
                             % (stdout, str(e)))
  
      log("extracted version: '%s'" % str(version))
      return version
docs: Run an executable and get the program version.
  
      Args:
          exepath: Filepath to executable.
          version_arg: Arg to pass to program, eg "-V". Can also be a list.
          word_index: Expect the Nth word of output to be the version.
          version_rank: Cap the version to this many tokens.
  
      Returns:
          `Version` object.