skbuild package

scikit-build is an improved build system generator for CPython C extensions.

This module provides the glue between the setuptools Python module and CMake.

skbuild.setup(*args, **kw)[source]

This function wraps setup() so that we can run cmake, make, CMake build, then proceed as usual with setuptools, appending the CMake-generated output as necessary.

The CMake project is re-configured only if needed. This is achieved by (1) retrieving the environment mapping associated with the generator set in the CMakeCache.txt file, (2) saving the CMake configure arguments and version in skbuild.constants.CMAKE_SPEC_FILE: and (3) re-configuring only if either the generator or the CMake specs change.

Submodules

skbuild.cmaker module

This module provides an interface for invoking CMake executable.

class skbuild.cmaker.CMaker(cmake_executable='cmake')[source]

Bases: object

Interface to CMake executable.

static check_for_bad_installs()[source]

This function tries to catch files that are meant to be installed outside the project root before they are actually installed.

Indeed, we can not wait for the manifest, so we try to extract the information (install destination) from the CMake build files *.cmake found in skbuild.constants.CMAKE_BUILD_DIR.

It raises skbuild.exceptions.SKBuildError if it found install destination outside of skbuild.constants.CMAKE_INSTALL_DIR.

configure(clargs=(), generator_name=None, skip_generator_test=False, cmake_source_dir='.', cmake_install_dir='', languages=('C', 'CXX'), cleanup=True)[source]

Calls cmake to generate the Makefile/VS Solution/XCode project.

clargs: tuple
List of command line arguments to pass to cmake executable.
generator_name: string
The string representing the CMake generator to use. If None, uses defaults for your platform.
skip_generator_test: bool
If set to True and if a generator name is specified (either as a keyword argument or as clargs using -G <generator_name>), the generator test is skipped.
cmake_source_dir: string
Path to source tree containing a CMakeLists.txt
cmake_install_dir: string
Relative directory to append to skbuild.constants.CMAKE_INSTALL_DIR.
languages: tuple
List of languages required to configure the project and expected to be supported by the compiler. The language identifier that can be specified in the list corresponds to the one recognized by CMake.
cleanup: bool
If True, cleans up temporary folder used to test generators. Set to False for debugging to see CMake’s output files.

Return a mapping of the environment associated with the selected skbuild.platform_specifics.abstract.CMakeGenerator.

Mapping of the environment can also be later retrieved using get_cached_generator_env().

get_cached_generator_env()[source]

If any, return a mapping of environment associated with the cached generator.

get_cached_generator_name()[source]

Reads and returns the cached generator from the skbuild.constants.CMAKE_BUILD_DIR:. Returns None if not found.

static get_python_include_dir(python_version)[source]

Get include directory associated with the current python interpreter.

static get_python_library(python_version)[source]

Get path to the python library associated with the current python interpreter.

static get_python_version()[source]

Get version associated with the current python interpreter.

install()[source]

Returns a list of file paths to install via setuptools that is compatible with the data_files keyword argument.

make(clargs=(), config='Release', source_dir='.', env=None)[source]

Calls the system-specific make program to compile code.

skbuild.cmaker.get_cmake_version(cmake_executable='cmake')[source]

Runs CMake and extracts associated version information. Raises skbuild.exceptions.SKBuildError if it failed to execute CMake.

skbuild.cmaker.has_cmake_cache_arg(cmake_args, arg_name, arg_value=None)[source]

Return True if -D<arg_name>:TYPE=<arg_value> is found in cmake_args. If arg_value is None, return True only if -D<arg_name>: is found in the list.

skbuild.cmaker.pop_arg(arg, args, default=None)[source]

Pops an argument arg from an argument list args and returns the new list and the value of the argument if present and a default otherwise.

skbuild.compat module

skbuild.compat.which(name, flags=1)[source]

Analogue of unix ‘which’. Borrowed from the Twisted project, see their licence here: https://twistedmatrix.com/trac/browser/trunk/LICENSE

Copied from pytest_shutil.cmdline.which to allow testing on conda-forge where pytest-shutil is not available.

skbuild.constants module

This module defines constants commonly used in scikit-build.

skbuild.constants.CMAKE_BUILD_DIR = '_skbuild/linux-x86_64-2.7/cmake-build'

CMake build directory.

skbuild.constants.CMAKE_DEFAULT_EXECUTABLE = 'cmake'

Default path to CMake executable.

skbuild.constants.CMAKE_INSTALL_DIR = '_skbuild/linux-x86_64-2.7/cmake-install'

CMake install directory.

skbuild.constants.CMAKE_SPEC_FILE = '_skbuild/linux-x86_64-2.7/cmake-build/CMakeSpec.json'

CMake specification file storing CMake version, CMake configuration arguments and environment variables PYTHONNOUSERSITE and PYTHONPATH.

skbuild.constants.SETUPTOOLS_INSTALL_DIR = '_skbuild/linux-x86_64-2.7/setuptools'

Setuptools install directory.

skbuild.constants.SKBUILD_DIR = '_skbuild/linux-x86_64-2.7'

Top-level directory where setuptools and CMake directories are generated.

skbuild.exceptions module

This module defines exceptions commonly used in scikit-build.

exception skbuild.exceptions.SKBuildError[source]

Bases: exceptions.RuntimeError

Exception raised when an error occurs while configuring or building a project.

exception skbuild.exceptions.SKBuildGeneratorNotFoundError[source]

Bases: skbuild.exceptions.SKBuildError

Exception raised when no suitable generator is found for the current platform.

skbuild.setuptools_wrap module

This module provides functionality for wrapping key infrastructure components from distutils and setuptools.

skbuild.setuptools_wrap.create_skbuild_argparser()[source]

Create and return a scikit-build argument parser.

skbuild.setuptools_wrap.parse_args()[source]

This function parses the command-line arguments sys.argv and returns the tuple (setuptools_args, cmake_executable, skip_generator_test, cmake_args, build_tool_args) where each *_args element corresponds to a set of arguments separated by --.

skbuild.setuptools_wrap.parse_skbuild_args(args, cmake_args, build_tool_args)[source]

Parse arguments in the scikit-build argument set. Convert specified arguments to proper format and append to cmake_args and build_tool_args. Returns the tuple (remaining arguments, cmake executable, skip_generator_test).

skbuild.setuptools_wrap.setup(*args, **kw)[source]

This function wraps setup() so that we can run cmake, make, CMake build, then proceed as usual with setuptools, appending the CMake-generated output as necessary.

The CMake project is re-configured only if needed. This is achieved by (1) retrieving the environment mapping associated with the generator set in the CMakeCache.txt file, (2) saving the CMake configure arguments and version in skbuild.constants.CMAKE_SPEC_FILE: and (3) re-configuring only if either the generator or the CMake specs change.

skbuild.setuptools_wrap.strip_package(package_parts, module_file)[source]

Given package_parts (e.g. ['foo', 'bar']) and a module_file (e.g. foo/bar/jaz/rock/roll.py), starting from the left, this function will strip the parts of the path matching the package parts and return a new string (e.g jaz/rock/roll.py).

The function will work as expected for either Windows or Unix-style module_file and this independently of the platform.