How to install Python package from source on Windows

Nathan Ernst nathan.ernst at gmail.com
Tue May 16 23:32:45 EDT 2017


MS used to, I'm not sure if they still do, provide a separate C++ SDK that
included the compiler, but not the full IDE. It was still quite a large
download at ~128MB. But, it included only the command-line compiler, linker
& std lib.

Starting with VS2017, the ABI is supposedly stable going foward (I've not
tested this) and the install is far more customizable. It's still quite a
hefty download, but you don't need the full 8GB just to be able to build a
python extension or python from source.

I don't think I've ever compiled python from source on windows (I most
certainly have on linux, and it's not hard), but I have compiled a number
of 3rd party libs. You simply need the requisite tools to do it. If you
don't have the tools, it's a futile effort. VS2015, VS2017 community
editions are free and provide the tools needed. They even include the
optimizing compiler, which used to be a premium. (VC6-VC7 days). The newest
runtimes only target windows 8 or later. With some effort to the build
scripts, one might be able to get it to build against an older C++ runtime,
but it certainly will not be supported.

Deborah, long term, you have to realize that if you insist on sticking to
WinXP, the rest of the world will, eventually, leave you behind.Software
vendors want to support the fewest platforms/configurations as possible. XP
is not supported by MS, so it makes no economic sense to an ISV to support
XP.

On Tue, May 16, 2017 at 8:56 PM, Terry Reedy <tjreedy at udel.edu> wrote:

> On 5/16/2017 5:30 AM, Mark Summerfield via Python-list wrote:
>
>> I think the problem that Deborah has encountered is a more general one on
>> Windows: many pip-installable packages assume that a C compiler is
>> available.
>>
>> Now an "obvious" solution is for pip to recognise that a C compiler is
>> needed and give an appropriate error message. But while that may reduce
>> confusion, it won't actually help someone who wants to install a Python
>> package that needs a C compiler.
>>
>> Of course, the error message could give a link to the appropriate
>> compiler. And then the user (who presumably isn't a Windows compiler
>> expert) will if they're really lucky get to download and install an
>> enormous Visual Studio compiler. Of course they may not be so lucky and
>> may discover that the installer tells them that they need some component
>> (and may or may not give the link to get it). And then they get that
>> component and, you guessed it, that component says it needs another
>> component, ... and eventually you end up with all the pieces. And even
>> then it doesn't necessarily work. (This has happened to me more than
>> once.)
>>
>> Here's a fantasy:
>>
>> C:\> pip install pkg_needs_c
>> Error: the pkg_needs_c package needs development tools which haven't been
>> found on this computer.
>> Run pip install --listtools pkg_needs_c for information on the required
>> tools or run pip install --useprebuilt pkg_needs_c to download prebuilt
>> components so no additional development tools are needed.
>>
>> C:\> pip install --listtools pkg_needs_c
>> The pkg_needs_c needs Visual Studio 2015 (which itself may have additional
>> dependencies). This can be downloaded from http://www....
>>
>> C:\> pip install --useprebuilt pkg_needs_c
>> ...
>>
>> This will send the minimum necessary details of the machine back to PyPI
>> which will then do a request on a Windows server farm which will send back
>> a matching pre-built package (building the package the first time it is
>> needed).
>>
>> I have no idea if this is possible/practical!
>>
>
> The problem is that 'compiles with gcc' is not the same as 'compiles with
> vc'.  The CPython C sources have numerous ifdefs for Windows, Darwin (Mac),
> Unix, and specific unix varieties.  Package developers who *have*
> successfully compiled on Windows should like provide wheels.
>
> Christoph Gohlke, http://www.lfd.uci.edu/~gohlke/pythonlibs/
> who has done us service of compiling over 300 packages on Windows,
> offers patches back to developers who will accept them.
>
> A server farm would need a person with a similar talent for adaptation.
>
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list