or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build-commands.mdcmake-interface.mdconstants-utilities.mdexception-handling.mdindex.mdplatform-integration.mdsetup-configuration.md
tile.json

tessl/pypi-scikit-build

Improved build system generator for Python C/C++/Fortran/Cython extensions

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/scikit-build@0.18.x

To install, run

npx @tessl/cli install tessl/pypi-scikit-build@0.18.0

index.mddocs/

scikit-build

An improved build system generator for Python C/C++/Fortran/Cython extensions that serves as glue between setuptools and CMake. scikit-build provides enhanced build capabilities for projects that need to compile native code extensions, offering cross-platform compatibility and automated handling of complex build processes.

Package Information

  • Package Name: scikit-build
  • Language: Python
  • Installation: pip install scikit-build

Core Imports

from skbuild import setup

Basic usage typically only requires importing the setup function:

from skbuild import setup, __version__

For advanced configuration:

from skbuild import setup
from skbuild.constants import CMAKE_INSTALL_DIR, CMAKE_BUILD_DIR
from skbuild.exceptions import SKBuildError

Basic Usage

from skbuild import setup

setup(
    name="my-extension",
    version="1.0.0",
    description="Python extension with C++ code",
    author="Your Name",
    
    # scikit-build specific options
    cmake_args=["-DCMAKE_BUILD_TYPE=Release"],
    cmake_source_dir="src",
    cmake_install_dir="",
    cmake_languages=["C", "CXX"],
    
    # Standard setuptools options
    packages=["my_extension"],
    python_requires=">=3.7",
)

Architecture

scikit-build bridges the gap between Python's setuptools ecosystem and CMake's powerful build system capabilities through several key components:

  • Setup Function: Enhanced replacement for setuptools.setup() with CMake integration
  • CMaker Interface: Direct interface to CMake executable for configuration and building
  • Platform Abstraction: Platform-specific handling of generators and build environments
  • Build Commands: Custom setuptools commands that integrate CMake into the build process
  • Constants and Utilities: Helper functions and configuration constants for build management

This design enables developers to create and distribute Python packages that include compiled extensions while maintaining compatibility with modern Python packaging standards and providing robust tooling for managing dependencies, build configurations, and platform-specific compilation requirements across different operating systems and architectures.

Capabilities

Setup and Configuration

Enhanced setup function that replaces setuptools.setup() with integrated CMake build system support. Handles CMake configuration, argument parsing, and build orchestration while maintaining full compatibility with setuptools features.

def setup(
    *,
    cmake_args: Sequence[str] = (),
    cmake_install_dir: str = "",
    cmake_source_dir: str = "",
    cmake_with_sdist: bool = False,
    cmake_languages: Sequence[str] = ("C", "CXX"),
    cmake_minimum_required_version: str | None = None,
    cmake_process_manifest_hook: Callable[[list[str]], list[str]] | None = None,
    cmake_install_target: str = "install",
    **kw: Any,
) -> upstream_Distribution

Setup and Configuration

CMake Interface

Direct interface to CMake executable for project configuration, building, and installation. Provides programmatic access to CMake operations with Python integration for version detection, cache management, and platform-specific build handling.

class CMaker:
    def __init__(self, cmake_executable: str = CMAKE_DEFAULT_EXECUTABLE) -> None: ...
    def configure(self, clargs: Sequence[str] = (), generator_name: str | None = None, skip_generator_test: bool = False, cmake_source_dir: str = ".", cmake_install_dir: str = "", languages: Sequence[str] = ("C", "CXX"), cleanup: bool = True) -> dict[str, str]: ...
    def make(self, clargs: Sequence[str] = (), config: str = "Release", source_dir: str = ".", install_target: str = "install", env: Mapping[str, str] | None = None) -> None: ...
    def install(self) -> list[str]: ...

CMake Interface

Constants and Utilities

Configuration constants, directory path functions, and utility functions for build management. Includes platform detection, directory creation, path manipulation, and build artifact management.

# Directory functions
def SKBUILD_DIR() -> str: ...
def CMAKE_BUILD_DIR() -> str: ...
def CMAKE_INSTALL_DIR() -> str: ...

# Platform functions  
def skbuild_plat_name() -> str: ...
def set_skbuild_plat_name(plat_name: str) -> None: ...

# Utility functions
def mkdir_p(path: str) -> None: ...
def to_platform_path(path: OptStr) -> OptStr: ...
def to_unix_path(path: OptStr) -> OptStr: ...

Constants and Utilities

Exception Handling

Exception classes for error handling during CMake configuration, building, and installation processes. Provides specific error types for different failure scenarios.

class SKBuildError(RuntimeError): ...
class SKBuildInvalidFileInstallationError(SKBuildError): ...
class SKBuildGeneratorNotFoundError(SKBuildError): ...

Exception Handling

Build Commands

Custom setuptools command classes that extend standard distutils/setuptools commands with CMake integration. These commands handle the build process orchestration between Python packaging and CMake.

class build: ...
class build_py: ...
class build_ext: ...
class install: ...
class clean: ...
class sdist: ...
class bdist_wheel: ...

Build Commands

Platform Integration

Platform-specific functionality for CMake generator detection, selection, and cross-platform build configuration. Provides automatic platform detection and generator compatibility testing.

def get_platform(): ...
class CMakeGenerator: ...
class CMakePlatform: ...

Platform Integration

Types

# Type aliases from _compat.typing
Protocol: type
TypedDict: type  
Final: type
Literal: type
NamedTuple: type

# External types from dependencies
upstream_Distribution = setuptools.dist.Distribution
Version = packaging.version.Version

# Optional string type
OptStr = str | None

# Version information types
version: str
__version__: str
version_tuple: tuple[int, int, int, str, str] | tuple[int, int, int]
__version_tuple__: tuple[int, int, int, str, str] | tuple[int, int, int]