How to install Python package from source on Windows

Terry Reedy tjreedy at udel.edu
Tue May 16 21:56:25 EDT 2017


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




More information about the Python-list mailing list