Esempio n. 1
0
def test_activation_logic(bits, compiler):
    from conda_build.windows import msvc_env_cmd
    # empty list here means no configuration is valid.  We should get a
    # failure.
    write_bat_files([])
    # look up which VS version we're forcing here
    compiler_version = [key for key in vcs if compiler in vcs[key]][0]
    with open('tmp_call.bat', "w") as f:
        f.write(msvc_env_cmd(bits, compiler_version))
    subprocess.check_call(['cmd.exe', '/C', 'tmp_call.bat'], shell=True)
def test_activation(bits, compiler):
    write_bat_files([compiler])
    from conda_build.windows import msvc_env_cmd, VS_VERSION_STRING
    # look up which VS version we're forcing here
    compiler_version = [key for key in vcs if compiler in vcs[key]][0]
    # this will throw an exception if the subprocess return code is not 0
    #     this is effectively the test condition for all below tests.
    with open('tmp_call.bat', "w") as f:
        f.write(msvc_env_cmd(bits, compiler_version))
        f.write('\nif not %VS_VERSION% == "{}" exit /b 1'.format(compiler_version))
        f.write('\nif not %VS_MAJOR% == "{}" exit /b 1'.format(compiler_version.split('.')[0]))
        f.write('\nif not %VS_YEAR% == "{}" exit /b 1'.format(VS_VERSION_STRING[compiler_version][-4:]))
        f.write('\nif not %CMAKE_GENERATOR% == "{}" exit /b 1'.format(VS_VERSION_STRING[compiler_version] +
                                                                      {64: ' Win64', 32: ''}[bits]))
    try:
        subprocess.check_call(['cmd.exe', '/C', 'tmp_call.bat'], shell=True)
    except subprocess.CalledProcessError:
        print("failed activation: {}, {}".format(bits, compiler))
        raise
    finally:
        os.remove('tmp_call.bat')
def windows_build(m):
    from conda_build.windows import msvc_env_cmd, kill_processes

    env = dict(os.environ)
    env.update(environ.get_dict(m))
    env = environ.prepend_bin_path(env, config.build_prefix, True)

    for name in 'BIN', 'INC', 'LIB':
        path = env['LIBRARY_' + name]
        if not isdir(path):
            os.makedirs(path)

    src_dir = source.get_dir()
    bld_bat = join(m.path, 'bld_wheel.bat')
    if exists(bld_bat):
        with open(bld_bat) as fi:
            data = fi.read()
    else:
        print("Using plain 'python setup.py bdist_wheel'  as build script")
        data = "\n:: Autogenerated build command:\npython setup.py bdist_wheel\n"

    with open(join(src_dir, 'bld.bat'), 'w') as fo:
        fo.write('@echo on\n')
        fo.write(msvc_env_cmd(override=m.get_value('build/msvc_compiler', None)))
        fo.write('\n')
        # more debuggable with echo on
        fo.write('set\n')
        fo.write('where python\n')
        fo.write('@echo on\n')
        fo.write("set INCLUDE={};%INCLUDE%\n".format(env["LIBRARY_INC"]))
        fo.write("set LIB={};%LIB%\n".format(env["LIBRARY_LIB"]))
        fo.write("REM ===== end generated header =====\n")
        fo.write(data)

    cmd = [os.environ['COMSPEC'], '/c', 'call', 'bld.bat']
    print("build cmd: %s" % cmd)
    _check_call(cmd, cwd=src_dir, env={str(k): str(v) for k, v in env.items()})
    kill_processes()