Scikit-build

0.19.0 · active · verified Sat Apr 11

Scikit-build is a Python build system that acts as a glue layer between `setuptools` and `CMake` to facilitate the building of CPython C/C++/Fortran/Cython extensions. It is currently at version 0.19.0 and has an active development cycle, with a focus on fixing bugs and improving compatibility. The next generation, `scikit-build-core`, is under active development and offers a more modern, standalone approach without direct reliance on `setuptools`.

Warnings

Install

Imports

Quickstart

To use scikit-build, you typically define your build requirements in `pyproject.toml`, replace `setuptools.setup` with `skbuild.setup` in your `setup.py`, and provide a `CMakeLists.txt` to describe how to build your C/C++/Fortran/Cython extensions. The `packages` argument in `setup()` helps scikit-build locate your Python modules, which will then be combined with artifacts built by CMake. A simple `hello` subdirectory with `_hello.cxx` (your C++ source) and an empty `__init__.py` is a common starting point.

# pyproject.toml
[build-system]
requires = ["setuptools>=42", "scikit-build>=0.13", "cmake>=3.18", "ninja"]
build-backend = "setuptools.build_meta"

[project]
name = "hello-cpp"
version = "0.0.1"

# setup.py
# This file would be in the same directory as pyproject.toml
# In a 'hello' subdirectory, you would have a '_hello.cxx' and '__init__.py'
# In the project root, you would also have a 'CMakeLists.txt'

from skbuild import setup

setup(
    name="hello-cpp",
    version="0.0.1",
    description="A minimal C++ extension package using scikit-build",
    author='The scikit-build team',
    license="MIT",
    packages=['hello'],
    python_requires=">=3.8",
)

# CMakeLists.txt (example content, not runnable Python):
# cmake_minimum_required(VERSION 3.18...3.22)
# project(hello CXX)
# find_package(PythonExtensions REQUIRED)
# add_library(_hello MODULE hello/_hello.cxx)
# python_extension_module(_hello)
# install(TARGETS _hello LIBRARY DESTINATION hello)

view raw JSON →