How does pip find the C++ compiler?

Hello, some python packages include pyd files that must be built with a C++ compiler. But how does pip find a C++ compiler? We all happen to run into errors of this kind:
error: Microsoft Visual C++ 14.0 or greater is required
The problem is that even after installing the Microsoft tools to build C++ apps, the problem persists. It would be nice to know which environment variables (I guess) pip relies on to build files.

Finding the compiler is only the start of the issues when a binary wheel is missing for windows.

Typically you then need to build of all the dependancies, header files and libraries, etc. And to build the dependancies can be complex in its own right.

I’m not talking about an issue in particular, I’m asking a question about the internals of pip. Understanding these internals will help solve the potential issues.

Pip itself is not responsible for finding the compiler. It will delegate the task of building the package to a build backend that is defined by the package being installed, in the [build-system] table of its pyproject.toml file. You should read the pyproject.toml in the source distribution of the project you’re trying to install (you can download the sdist, which is a .tar.gz archive, from the “Files” tab of the project page on PyPI).

(If the project does not contain a pyproject.toml file, then Pip will fallback to the setuptools build backend for backwards compatibility reasons.)

Thanks for your reply. Here is what the [build-system] section looks like:

requires = [
build-backend = “setuptools.build_meta”

So, I guess everything happens in that “setuptools.build_meta”. So, must I ask my question in setuptools’ github?

First, you should read the setuptools documentation. Specifically, this section is relevant: Building Extension Modules - setuptools 68.2.2.post20231016 documentation . Afterwards, if you have not found your answer, then yes, open an issue in the setuptools issue tracker.

Ok thanks.