How to install Python package from source on Windows

Michael Torrie torriem at gmail.com
Tue May 16 19:42:47 EDT 2017


On 05/16/2017 05:01 PM, bartc wrote:
> And it sounds like the CPython developers have never used a compiler 
> other than gcc or MSVC, and the latter only reluctantly.

It's more a matter of choosing the best compiler to support the many
different platforms you wish to support.  GCC is the defacto
cross-platform compiler.  It makes sense to target it. If you stick to
the standards then you can can quite easily use different compilers on
certain platforms.

The real crux of the issue with Python on Windows comes down to a few
factors. First, nearly all developers use Visual Studio on Windows.
Second, all Windows programs must link against a version of the MS C
Standard library, which until recently was synced with releases of
Visual Studio.  This is of particular importance to people who embed
Python in their own software, or write extension modules in C or C++.
The problem is that you really can't safely use more than one C runtime
DLL at a time.  So if Python was built against MingW GCC, that for many
years was fixed to an older version of the MSVCRT.dll, if someone wanted
to write an extension for Python in VS, they'd have problems.  Of course
this is an issue for different versions of VS as well, but now that MS
has released the universal C runtime DLL, you can now use a different
version of VS to build extensions than the one that build Python itself
(but not on XP).

Also there's the issue of C++ ABI compatibility across compilers (there
is none).  So it makes sense to use the platform's dominant (default
even) compiler.  GCC for *nix, Clang for OS X, VS for Windows, etc.

> But since this is all apparently so easy for everyone else here accept 
> me, let one of them do this experiment: get CPython source code, compile 
> it with an alternative small compiler (Tiny C is one), and see how it 
> compares with CPython compiled with gcc or MSVC.
> 
> It should be a piece of cake, yes?

If TCC implements the standard sufficiently, then yes it's possible.
However it won't be easy because the Python build tools are geared
towards the dominant compilers (GCC and VS), so you'd have to rework all
the build batch files first.  Building an executable involves more than
just compiling a C file. There is dependency calculation, optional
compilation of features, linking, etc.




More information about the Python-list mailing list