set DISTUTILS_USE_SDK=1
set MSSdk=1

if %PY_VER%==2.7 (
    set VS=vs2008
    REM set COMP_DIR=C:\localdisk\tools\intel\composer_xe_2013_sp1.5.239 ENV_VAR problems
    set IFORT_ENV_BAT="C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\compilervars_arch.bat"

    @rem Allows building using VS2008
    copy %RECIPE_DIR%\stdint.h %LIBRARY_INC%
) else (
    set "PY_VCRUNTIME_REDIST=%LIBRARY_BIN%\vcruntime140.dll"
    set VS=vs2015
    REM set COMP_DIR="C:\localdisk\tools\intel\parallel_studio_xe_2016.3.059\compilers_and_libraries_2016\windows" ENV_VAR problems
    set IFORT_ENV_BAT="C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2016.3.059\compilers_and_libraries_2016\windows\bin\compilervars_arch.bat"
)

call %IFORT_ENV_BAT% intel64 %VS%
if errorlevel 1 exit 1

if "%ARCH%"=="64" (
    set INTEL_ARCH=intel64
) else (
    set INTEL_ARCH=ia32
)
@rem call "%COMP_DIR%\bin\ifortvars.bat" %INTEL_ARCH% %VS%
@rem Intel Fortran Compilers 2016 Update 3 remove support for vs2008.
@rem ifortvars.bat adds vs2010 (or vs2015) to front of PATH to affect
@rem this change. So we undo that here in a somewhat horrible manner.
@rem if %VS_YEAR%==2008 (
@rem     if "%ARCH%"=="64" (
@rem         call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" amd64
@rem     ) else (
@rem         call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
@rem     )
@rem )

@rem This *should* be MKLROOT (since that's what Intel use)
@rem See numpy PR: https://github.com/numpy/numpy/pull/7723
@rem The goal is to avoid using:
@rem envs/_build/lib/site-packages/numpy/distutils/site.cfg in which we get
@rem build-time baked paths, meaning if it was built on a different machine
@rem to the current one you're trying to build scipy on those paths may not
@rem exist.
set "MKL=%LIBRARY_PREFIX%"

%PYTHON% setup.py build --force --compiler=intelemw --fcompiler=intelvem
%PYTHON% setup.py install  --old-and-unmanageable
if errorlevel 1 exit 1
