After going through quite a pain getting my python setup.py to work with setuptools and the dedicated microsoft VC (Microsoft Visual C++ Compiler Package for Python 2.7) and succesfully compiling my extension on windows 10 it turns out the Maya 2017 included python executable (mayapy) is compiled with a different version, see below.
c:>python
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32
c:>"Program Files\Autodesk\Maya2017\bin\mayapy.exe"
Python 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit (AMD64)] on win32
I have Visual Studio 12 installed as well and that seems to be the right compiler version.
But how can I tell setuptools to use that version?
Thanks
The quick and dirty way is to use to compile the required DLL on the command line using the Command Prompt for the VS2012 x64 Native Tools. The version that matches the mayapy.exe in Maya 2017.
To compile your c code use cl. You may need to point to the Python 2.7 include files using /I.

cl /DL /I ..\include /I C:\Python27\include 

Because the linker might have trouble finding the 'python27.lib' you can link manually as well using /LIBPATH to point to the Python 2.7 libs directory.

link /DLL /LIBPATH:C:\Python27\libs *.obj

This will give you a DLL and intermediate files matching the compiler for mayapy.exe.
The dirty part.
Build the extension using python setup.py build. This will give you a module that will import in the regular python interpreter. Remove the 'lib*' directory in the 'build' folder. Copy the '.obj', '.exp' and the dll to the temp folder in your build folder, something like 'temp.win-amd64-2.7\Release\\src'.
Then run python setup.py build again.
Dirty yes, Quick, once you know what to do...
How can I compile python c extension for the Window 10 Maya 2017 python?