C Runtime, Compiler and Build System Generator

scikit-build uses sensible defaults allowing to select the C runtime matching the official CPython recommendations. It also ensures developers remain productive by selecting an alternative environment if recommended one is not available.

The table below lists the different C runtime implementations, compilers and their usual distribution mechanisms for each operating systems.

  Linux MacOSX Windows
C runtime GNU C Library (glibc) libSystem library Microsoft C run-time library
Compiler GNU compiler (gcc) clang Microsoft C/C++ Compiler (cl.exe)
Provenance Package manager OSX SDK within XCode

Build system generator

Since scikit-build simply provides glue between setuptools and CMake, it needs to choose a CMake generator to configure the build system allowing to build of CPython C extensions.

The table below lists the generator supported by scikit-build:

Operating System Linux MacOSX Windows
CMake Generator
  1. Ninja
  2. Unix Makefiles
  1. Ninja
  2. Visual Studio
  3. NMake Makefiles
  4. NMake Makefiles JOM

When building a project, scikit-build iteratively tries each generator (in the order listed in the table) until it finds a working one.

For more details about CMake generators, see CMake documentation.

Ninja

  • Supported platform(s): Linux, MacOSX and Windows
  • If ninja executable is in the PATH, the associated generator is used to setup the project build system based on ninja files.

Note

Automatic parallelism

An advantage of ninja is that it automatically parallelizes the build based on the number of CPUs.

Note

Ninja on Windows

When Ninja generator is used on Windows, scikit-build will make sure the project is configured and built with the appropriate [2] environment (equivalent of calling vcvarsall.bat x86 or vcvarsall.bat amd64).

Unix Makefiles

  • Supported platform(s): Linux, MacOSX
  • scikit-build uses this generator to generate a traditional Makefile based build system.

Visual Studio IDE

  • Supported platform(s): Windows
  • scikit-build uses the generator corresponding to selected version of Visual Studio and generate a solution file based build system.
  Architecture
CPython Version x86 (32-bit) x64 (64-bit)
3.5 and above Visual Studio 14 2015 Visual Studio 14 2008 Win64
3.3 to 3.4 Visual Studio 10 2010 Visual Studio 10 2010 Win64
2.7 to 3.2 Visual Studio 9 2008 Visual Studio 9 2008 Win64

Note

The Visual Studio generators can not be used when only alternative environments are installed, in that case Ninja or NMake Makefiles are used.

NMake Makefiles

  • Supported platform(s): Windows
  • scikit-build will make sure the project is configured and built with the appropriate [2] environment (equivalent of calling vcvarsall.bat x86 or vcvarsall.bat amd64).

Note

NMake Makefiles JOM

The NMake Makefiles JOM generator is supported but it is not automatically used by scikit-build (even if jom executable is in the PATH), it always needs to be explicitly specified. For example:

python setup.py build -G "NMake Makefiles JOM"

For more details, see scikit-build options.

Linux

scikit-build uses the toolchain set using CC (and CXX) environment variables. If no environment variable is set, it defaults to gcc.

To build compliant Linux wheels, scikit-build also supports the manylinux platform described in PEP-0513. We recommend the use of dockcross/manylinux-x64 and dockcross/manylinux-x86. These images are optimized for building Linux wheels using scikit-build.

Windows

Microsoft C run-time and Visual Studio version

On windows, scikit-build looks for the version of Visual Studio matching the version of CPython being used. The selected Visual Studio version also defines which Microsoft C run-time and compiler are used:

Python version 2.7 to 3.2 3.3 to 3.4 3.5 and above
Microsoft C run-time msvcr90.dll msvcr100.dll ucrtbase.dll
Compiler version MSVC++ 9.0 MSVC++ 10.0 MSVC++ 14.0
Visual Studio version 2008 2010 2015

Installing compiler and Microsoft C run-time

As outlined above, installing a given version of Visual Studio will automatically install the corresponding compiler along with the Microsoft C run-time libraries.

This means that if you already have the corresponding version of Visual Studio installed, your environment is ready.

Nevertheless, since older version of Visual Studio are not available anymore, this next table references links for installing alternative environments:

Download links for Windows SDK and Visual Studio.
CPython version Download links for Windows SDK or Visual Studio
3.5 and above

or

3.3 to 3.4 Windows SDK for Windows 7 and .NET 4.0
2.7 to 3.2 Microsoft Visual C++ Compiler for Python 2.7

These links have been copied from the great article [1] of Steve Dower, engineer at Microsoft.

Footnotes

[1]How to deal with the pain of “unable to find vcvarsall.bat”
[2](1, 2) Implementation details: This is made possible by internally using the function query_vcvarsall from the distutils.msvc9compiler (or distutils._msvccompiler when visual studio >= 2015 is used). To ensure, the environment associated with the latest compiler is properly detected, the distutils modules are systematically patched using setuptools.monkey.patch_for_msvc_specialized_compiler().