[Python-Dev] Why is Python for Windows compiled with MSVC?

MRAB python at mrabarnett.plus.com
Wed Jan 31 15:31:09 EST 2018


On 2018-01-31 19:07, Ray Donnelly wrote:
> On Wed, Jan 31, 2018 at 3:04 PM, Oleg Sivokon <olegs at traiana.com> wrote:
>> Hello list.
>>
>> I'll give some background before asking my question in more detail.
>>
[snip]
>>
>> Now all I had to do was to re-create my success on Windows (most of the employees in my company use Windows).  At first I thought that I'd cross-compile on Linux using MinGW.  I compiled Go shared library into a DLL, then tried to compile my Python extension and... it didn't work.  I downloaded VirtualBox and some Windows images, etc... tried to compile on Windows.  It didn't work.  I started asking around, and was told that even though for some earlier versions of Python this was kind of possible, for Python 3.5, 3.6 it is not.  You must use MSVC to compile Python extensions.  No way around it.
>> Now, since Go won't compile with MSVC, I'll have to scrap my project and spend many weeks re-implementing kubectl.
>>
>> Here's my question: Why?
>>
>> Why did you choose to use non-free compiler, which also makes cross-compilation impossible?  There wasn't really a reason not to choose MinGW as a way to compile extensions on Windows (Ruby does that, Go uses MinGW, perhaps some others too).  It would've made things like CI and packaging so much easier...  What do Python users / developers get from using MSVC instead?
> 
> You can compile extension modules with mingw-w64 just fine (modulus a
> few gotchas). The Anaconda Distribution we do this for a few packages,
> for example rpy2. You can see the build script used here:
> https://github.com/AnacondaRecipes/rpy2-feedstock/blob/master/recipe/bld.bat
> (disclaimer: I work for Anaconda Inc on this stuff).
> 
> MSYS2 also have mingw-w64 builds of Python that might meet your needs.
> It is pretty popular in some parts of the open source on Windows world
> (disclaimer: I did a lot of the work for this stuff on MSYS2).
> I build the wheels (binaries for Windows) for the regex module using 
mingw-w64 and they also work just fine.

I can also build using Microsoft Visual Studio Community 2017 (which is 
free) and they work.

[snip]


More information about the Python-Dev mailing list