def _detect_msvc(ctx):
    from string import digits as string_digits

    msvc_version_info = (9, 0)
    msvc_version = "9.0"
    pdir = find_vc_pdir(msvc_version)
    if pdir is None:
        raise ValueError("VS 9.0 not found")

    # filter out e.g. "Exp" from the version name
    msvc_ver_numeric = ''.join([x for x in msvc_version if x in string_digits + "."])
    vernum = float(msvc_ver_numeric)
    if 7 <= vernum < 8:
        pdir = os.path.join(pdir, os.pardir, "Common7", "Tools")
        batfilename = os.path.join(pdir, "vsvars32.bat")
    elif vernum < 7:
        pdir = os.path.join(pdir, "Bin")
        batfilename = os.path.join(pdir, "vcvars32.bat")
    else: # >= 8
        batfilename = os.path.join(pdir, "vcvarsall.bat")

    vc_paths = get_output(ctx, batfilename, "x86")
    cc = None
    linker = None
    lib = None
    for p in vc_paths["PATH"]:
        _cc = os.path.join(p, "cl.exe")
        _linker = os.path.join(p, "link.exe")
        _lib = os.path.join(p, "lib.exe")
        if os.path.exists(_cc) and os.path.exists(_linker) and os.path.exists(_lib):
            cc = _cc
            linker = _linker
            lib = _lib
            break
    if cc is None or linker is None:
        raise RuntimeError("Could not find cl.exe/link.exe")

    return cc, linker, lib, vc_paths, msvc_version_info
dataset/ETHPy150Open cournape/Bento/bento/private/_yaku/yaku/tools/msvc.py/_detect_msvc/original