title: Force compiler when running python setup.py install
body: <p>Is there a way to explicitly force the compiler for building Cython extensions when running <code>python setup.py install</code>? Where <code>setup.py</code> is of the form:</p>
  <pre><code>import os.path
  import numpy as np
  from setuptools import setup, find_packages, Extension
  from Cython.Distutils import build_ext
  
  setup(name='test',
    packages=find_packages(),
    cmdclass={'build_ext': build_ext},
    ext_modules = [ Extension(&quot;test.func&quot;, [&quot;test/func.pyx&quot;]) ],
    include_dirs=[np.get_include()]
   )
  </code></pre>
  <p>I'm trying to install a package on Windows 8.1 x64 using Anaconda 3.16, Python 3.4, setuptools 18, NumPy 1.9 and Cython 0.24. The deployment script is adapted from the Cython <a href="https://github.com/cython/cython/wiki/CythonExtensionsOnWindows#using-windows-sdk-cc-compiler-works-for-all-python-versions" rel="nofollow noreferrer">wiki</a> and <a href="https://stackoverflow.com/a/13751649/1791279">this</a> Stack Overflow answer:</p>
  <p><strong>Makefile.bat</strong></p>
  <pre class="lang-none prettyprint-override"><code>:: create and activate a virtual environement with conda
  conda create --yes -n test_env cython setuptools=18 pywin32 libpython numpy=1.9 python=3
  call activate test_env
  
  :: activate the MS SDK compiler as explained in the Cython wiki
  cd C:\Program Files\Microsoft SDKs\Windows\v7.1\
  set MSSdk=1
  set DISTUTILS_USE_SDK=1
  @call .\Bin\SetEnv /x64 /release
  
  cd C:\test
  python setup.py install
  </code></pre>
  <p>The problem is that in this case <code>setup.py install</code> still used the MinGW compiler included with conda instead of the MS Windows SDK 7.1 one.</p>
  <ul>
  <li><p>So the <code>DISTUTILS_USE_SDK=1</code> and <code>MSSdk=1</code> don't seem to have an impact on the build. I'm not sure if activating the MS SDK from within a conda virtualenv might be an issue here.</p>
  </li>
  <li><p>Running <code>python setup.py build_ext --compiler=msvc</code> correctly builds the extension with the MS compiler, but subsequently running the <code>setup.py install</code> recompiles it with MinGW again. Same applies to <code>python setup.py build --compiler=msvc</code>.</p>
  </li>
  <li><p>Also tried running <code>%COMSPEC% /E:ON /V:ON /K &quot;%PROGRAMFILES%\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd&quot;</code> as discussed in the answer linked above, but for me this produces a new terminal prompt, colored in yellow, and stops the install process.</p>
  </li>
  </ul>
  <p>Is there a way of forcing the compiler for building this package, for instance, by editing the <code>setup.py</code>?</p>