def msvc_setup_env(env):
    debug('msvc_setup_env()')

    version = get_default_version(env)
    if version is None:
        warn_msg = "No version of Visual Studio compiler found - C/C++ " \
                   "compilers most likely not set correctly"

        # Nuitka: Useless warning for us.
        # SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg)
        return None
    debug('msvc_setup_env: using specified MSVC version %s' % repr(version))

    # XXX: we set-up both MSVS version for backward
    # compatibility with the msvs tool
    env['MSVC_VERSION'] = version
    env['MSVS_VERSION'] = version
    env['MSVS'] = {}


    use_script = env.get('MSVC_USE_SCRIPT', True)
    if SCons.Util.is_String(use_script):
        debug('msvc_setup_env() use_script 1 %s' % repr(use_script))
        d = script_env(use_script)
    elif use_script:
        d = msvc_find_valid_batch_script(env,version)
        debug('msvc_setup_env() use_script 2 %s' % d)
        if not d:
            return d
    else:
        debug('MSVC_USE_SCRIPT set to False')
        warn_msg = "MSVC_USE_SCRIPT set to False, assuming environment " \
                   "set correctly."
        # Nuitka: We use this on purpose.
        # SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg)
        return None

    for k, v in d.items():
        # Nuitka: Make the Windows SDK version visible in environment.
        if k == "WindowsSDKVersion":
            # Always just a single version if any.
            if len(v) == 1:
                env["WindowsSDKVersion"] = v[0].rstrip('\\')
            elif len(v) == 0:
                env["WindowsSDKVersion"] = None
            else:
                assert False, v

            continue

        debug('msvc_setup_env() env:%s -> %s'%(k,v))
        env.PrependENVPath(k, v, delete_existing=True)

    # final check to issue a warning if the compiler is not present
    msvc_cl = find_program_path(env, 'cl')
    if not msvc_cl:
        SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning,
            "Could not find MSVC compiler 'cl', it may need to be installed separately with Visual Studio")