-1

Does pip install always build extension modules with the same compiler that was used to compile the current Python version?

For example, this blog post explained that numpy package uses C code, which has to be compiled against the same compiler as the Python itself:

Python 2.7.13 (default, Aug 21 2017, 11:46:40) [MSC v.1900 64 bit (AMD64)] on win32

tells us which compiler was used. numpy and other packages have to be compiled against that identical version.

EvgenKo423
  • 976
  • 1
  • 13
  • 18
Nub
  • 21
  • 6

3 Answers3

0

Pip prioritises the version on your PATH. Pip3 and Pip are used to differentiate between the two versions.

https://docs.python.org/2/installing/index.html

0

pip install never installs a compiler. You have to have the compiler before running pip install.

See https://wiki.python.org/moin/WindowsCompilers to learn what version of VC you need to install for different versions of Python.

It would be much simpler to install a precompiled wheel. Said numpy has a lot of precompiled wheels. Currently there are binary wheels for Python 2.7, 3.5, 3.6 and 3.7 on MacOS 64 bits, Linux 32 and 64 bits, Windows 32 and 64 bits. Just type pip install numpy and your pip automatically determines what platform it's being ran on and download and install the proper wheel.

phd
  • 69,888
  • 11
  • 97
  • 133
0

Yes, pip is built on top of distutils package and by default it enforces extension modules to be compiled with the same compiler as an interpreter itself.

On Windows compiler version is also enforced to be the same (or, since Python 3.5, compatible). On Unix-likes the same compiler and linker flags used to compile Python will also be used to compile extensions.


Note that it's more of a convenience and safeguard rather than a requirement. Except for some special cases Python extensions should work just fine when built with another compiler version.

EvgenKo423
  • 976
  • 1
  • 13
  • 18