code: def get_tool_dir():
          
          def _is_comntools(name):
              return re.match(r'vs\d+comntools', name.lower())
  
          def _get_version_from_name(name):
              return (re.search(r'\d+', name).group(0), name)
  
          names = [name for name in os.environ if _is_comntools(name)]
          logging.debug(_('found vscomntools: %s'), names)
          versions = [_get_version_from_name(name) for name in names]
          logging.debug(_('extracted versions: %s'), versions)
          try:
              version = max(versions)
          except ValueError:
              raise OSError(_('Failed to find the VSCOMNTOOLS. '
                              'Have you installed Visual Studio?'))
          else:
              logging.info(_('using version: %s'), version)
              vscomntools = os.environ[version[1]]
              logging.info(_('using vscomntools: %s'), vscomntools)
              return vscomntools
docs: Get the directory of Visual Studio
          from environment variables.