scikit-build-core

A next generation Python CMake adaptor and Python API for plugins

https://github.com/scikit-build/scikit-build-core

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 11 committers (18.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.3%) to scientific vocabulary

Keywords

cmake python

Keywords from Contributors

jax scikit-hep open-science hep astronomy closember materials-informatics lammps deep-neural-networks computational-chemistry
Last synced: 6 months ago · JSON representation ·

Repository

A next generation Python CMake adaptor and Python API for plugins

Basic Info
Statistics
  • Stars: 372
  • Watchers: 12
  • Forks: 68
  • Open Issues: 134
  • Releases: 65
Topics
cmake python
Created over 3 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License Citation

README.md

scikit-build-core

Documentation Status GitHub Discussion Discord

Actions Status codecov

PyPI version Conda-Forge PyPI platforms Downloads

[!NOTE]

We have a public Scikit-build community meeting every month! Join us on Google Meet on the third Friday of every month at 12:00 PM EST. We also have a developer's meeting on the first Friday of every month at the same time. Our past meeting minutes are available here.

Scikit-build-core is a build backend for Python that uses CMake to build extension modules. It has a simple yet powerful static configuration system in pyproject.toml, and supports almost unlimited flexibility via CMake. It was initially developed to support the demanding needs of scientific users, but can build any sort of package that uses CMake.

Scikit-build-core is a ground-up rewrite of the classic Scikit-build. The key features of scikit-build classic (which is setuptools based) are also present here:

  • Great support for or by most OSs, compilers, IDEs, and libraries
  • Support for C++ features and other languages like Fortran
  • Support for multithreaded builds
  • Simple CMakeLists.txt files instead of up to thousands of lines of fragile setuptools/distutils code
  • Cross-compile support for Apple Silicon and Windows ARM

Scikit-build-core was built using Python packaging standards developed after scikit-build (classic) was written. Using it directly provides the following features over classic Scikit-build:

  • Better warnings, errors, and logging
  • No warning about unused variables
  • Automatically adds Ninja and/or CMake only as required
  • No dependency on setuptools, distutils, or wheel
  • Powerful config system, including config options support
  • Automatic inclusion of site-packages in CMAKE_PREFIX_PATH
  • FindPython is backported if running on CMake < 3.26.1 (configurable), supports PyPY SOABI & Limited API / Stable ABI
  • Limited API / Stable ABI and pythonless tags supported via config option
  • No slow generator search, ninja/make or MSVC used by default, respects CMAKE_GENERATOR
  • SDists are reproducible by default (UNIX, Python 3.9+, uncompressed comparison recommended)
  • Support for caching between builds (opt-in by setting build-dir)
  • Support for writing out to extra wheel folders (scripts, headers, data)
  • Support for selecting install components and build targets
  • Dedicated entrypoints for module and prefix directories
  • Several integrated dynamic metadata plugins (proposing standardized support soon)
  • Experimental editable mode support, with optional experimental auto rebuilds on import and optional in-place mode
  • Supports WebAssembly (Emscripten/Pyodide).
  • Supports free-threaded Python 3.13.

The following limitations are present compared to classic scikit-build:

  • The minimum supported CMake is 3.15
  • The minimum supported Python is 3.8 (3.7+ for 0.10.x and older)

Some known missing features that will be developed soon:

  • Wheels are not fully reproducible yet (nor are they in most others systems, including setuptools)
  • Several editable mode caveats (mentioned in the docs).

Other backends are also planned:

  • Setuptools integration highly experimental
  • Hatchling plugin highly experimental

The recommended interface is the native pyproject builder. There is also a WIP setuptools-based interface that is being developed to provide a transition path for classic scikit-build, and a WIP Hatchling plugin. Both might be moved to standalone packages in the future.

[!WARNING]

Only the pyproject-based builder should be used; the setuptools backend is experimental and likely to move to a separate package before being declared stable, and internal API is still being solidified. A future version of this package will support creating new build extensions.

Example

To use scikit-build-core, add it to your build-system.requires, and specify the scikit_build_core.build builder as your build-system.build-backend. You do not need to specify cmake or ninja; scikit-build-core will require them automatically if the system versions are not sufficient.

```toml [build-system] requires = ["scikit-build-core"] build-backend = "scikitbuildcore.build"

[project] name = "scikitbuildsimplest" version = "0.0.1" ```

You can (and should) specify the rest of the entries in project, but these are the minimum to get started.

An example CMakeLists.txt:

```cmake cmakeminimumrequired(VERSION 3.15...3.30) project(${SKBUILDPROJECTNAME} LANGUAGES C)

find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)

Pythonaddlibrary(module MODULE src/module.c WITHSOABI) install(TARGETS module DESTINATION ${SKBUILDPROJECT_NAME}) ```

Scikit-build-core will backport FindPython from CMake 3.26.1 to older versions of Python, and will handle PyPy for you if you are building from PyPy. You will need to install everything you want into the full final path inside site-modules (so you will usually prefix everything by the package name).

More examples are in the tests/packages.

Configuration

All configuration options can be placed in pyproject.toml, passed via -C/--config-setting in build or -C/--config-settings in pip , or set as environment variables. tool.scikit-build is used in toml, skbuild. for -C options, or SKBUILD_* for environment variables.

For a full reference and explanation of the variables see the online documentation

A quick summary and some defaults are listed below:

```toml [tool.scikit-build]

The versions of CMake to allow as a python-compatible specifier.

cmake.version = ""

A list of args to pass to CMake when configuring the project.

cmake.args = []

A table of defines to pass to CMake when configuring the project. Additive.

cmake.define = {}

The build type to use when building the project.

cmake.build-type = "Release"

The source directory to use when building the project.

cmake.source-dir = "."

The versions of Ninja to allow.

ninja.version = ">=1.5"

Use Make as a fallback if a suitable Ninja executable is not found.

ninja.make-fallback = true

The logging level to display.

logging.level = "WARNING"

Files to include in the SDist even if they are skipped by default. Supports gitignore syntax.

sdist.include = []

Files to exclude from the SDist even if they are included by default. Supports gitignore syntax.

sdist.exclude = []

Try to build a reproducible distribution.

sdist.reproducible = true

If set to True, CMake will be run before building the SDist.

sdist.cmake = false

A list of packages to auto-copy into the wheel.

wheel.packages = ["src/", "python/", ""]

The Python version tag used in the wheel file.

wheel.py-api = ""

Fill out extra tags that are not required.

wheel.expand-macos-universal-tags = false

The CMake install prefix relative to the platlib wheel path.

wheel.install-dir = ""

A list of license files to include in the wheel. Supports glob patterns.

wheel.license-files = ""

Run CMake as part of building the wheel.

wheel.cmake = true

Target the platlib or the purelib.

wheel.platlib = ""

A set of patterns to exclude from the wheel.

wheel.exclude = []

The build tag to use for the wheel. If empty, no build tag is used.

wheel.build-tag = ""

If CMake is less than this value, backport a copy of FindPython.

backport.find-python = "3.26.1"

Select the editable mode to use. Can be "redirect" (default) or "inplace".

editable.mode = "redirect"

Turn on verbose output for the editable mode rebuilds.

editable.verbose = true

Rebuild the project when the package is imported.

editable.rebuild = false

Extra args to pass directly to the builder in the build step.

build.tool-args = []

The build targets to use when building the project.

build.targets = []

Verbose printout when building.

build.verbose = false

Additional build-system.requires.

build.requires = []

The components to install.

install.components = []

Whether to strip the binaries.

install.strip = true

The path (relative to platlib) for the file to generate.

generate[].path = ""

The template string to use for the file.

generate[].template = ""

The path to the template file. If empty, a template must be set.

generate[].template-path = ""

The place to put the generated file.

generate[].location = "install"

A message to print after a build failure.

messages.after-failure = ""

A message to print after a successful build.

messages.after-success = ""

Add the python build environment site_packages folder to the CMake prefix paths.

search.site-packages = true

List dynamic metadata fields and hook locations in this table.

metadata = {}

Strictly check all config options.

strict-config = true

Enable early previews of features not finalized yet.

experimental = false

If set, this will provide a method for backward compatibility.

minimum-version = "0.11" # current version

The CMake build directory. Defaults to a unique temporary directory.

build-dir = ""

Immediately fail the build. This is only useful in overrides.

fail = false

```

Most CMake environment variables should be supported, and CMAKE_ARGS can be used to set extra CMake args. ARCHFLAGS is used to specify macOS universal2 or cross-compiles, just like setuptools.

You can also specify [[tool.scikit-build.overrides]] to customize values for different systems. See the docs for details.

Other projects for building

Scikit-build-core is a binary build backend. There are also other binary build backends:

  • py-build-cmake: A different attempt at a standards compliant builder for CMake. Strong focus on cross-compilation. Uses Flit internals.
  • cmeel: A different attempt at a standards compliant builder for CMake. Focus on building an ecosystem around a special unimportable folder in site-packages (similar to scikit-build's usage of cmake.* entrypoints, but folder-based).
  • meson-python: A meson-based build backend; has some maintainer overlap with scikit-build-core.
  • maturin: A build backend for Rust projects, using Cargo.
  • enscons: A SCons based backend, not very actively developed (but it predates all the others in modern standard support!)

If you don't need a binary build, you don't need to use a binary build backend! There are some very good Python build backends; we recommend hatchling as a good balance between good defaults for beginners and good support for advanced use cases. This is the tool scikit-build-core itself uses.

Acknowledgements

Support for this work was provided by NSF grant OAC-2209877. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

Owner

  • Name: scikit-build
  • Login: scikit-build
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
message: "Please cite this software using the metadata from 'preferred-citation'."
title: "Scikit-build-core"
version: "0.10.7"
date-released: "2024-10-20"
abstract: "Build compiled Python packages using CMake"
keywords:
  - python
  - cmake
authors:
  - family-names: Schreiner
    given-names: Henry
    name-suffix: III
    orcid: https://orcid.org/0000-0002-7833-783X
    affiliation: Princeton University
    website: https://iscinumpy.dev
    alias: henryiii
  - family-names: Fillion-Robin
    given-names: Jean-Christophe
    orcid: https://orcid.org/0000-0002-9688-8950
    affiliation: Kitware
    alias: jcfr
  - family-names: McCormick
    given-names: Matt
    orcid: https://orcid.org/0000-0001-9475-3756
    affiliation: Kitware
    alias: thewtex
  - family-names: Le
    given-names: Christian
    orcid: https://orcid.org/0000-0001-5122-8521
    alias: LecrisUT
url: https://scikit-build-core.readthedocs.io
repository-code: https://github.com/scikit-build/scikit-build-core
license: Apache-2.0
preferred-citation:
  type: conference-paper
  title: Scikit-build-core
  conference:
    name: SciPy 2024
  journal: Proceedings of the 23rd Python in Science Conference
  issn: 2575-9752
  date-published: 2024-07-10
  doi: 10.25080/FMKR8387
  license: CC-BY-4.0
  authors:
    - family-names: Schreiner
      given-names: Henry
      name-suffix: III
      orcid: https://orcid.org/0000-0002-7833-783X
      affiliation: Princeton University
      website: https://iscinumpy.dev
    - family-names: Fillion-Robin
      given-names: Jean-Christophe
      orcid: https://orcid.org/0000-0002-9688-8950
      affiliation: Kitware
    - family-names: McCormick
      given-names: Matt
      orcid: https://orcid.org/0000-0001-9475-3756
      affiliation: Kitware

GitHub Events

Total
  • Create event: 72
  • Release event: 5
  • Issues event: 135
  • Watch event: 125
  • Delete event: 58
  • Issue comment event: 568
  • Push event: 219
  • Pull request review comment event: 87
  • Pull request event: 207
  • Pull request review event: 118
  • Fork event: 21
Last Year
  • Create event: 72
  • Release event: 5
  • Issues event: 135
  • Watch event: 125
  • Delete event: 58
  • Issue comment event: 568
  • Push event: 219
  • Pull request review comment event: 87
  • Pull request event: 207
  • Pull request review event: 118
  • Fork event: 21

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 255
  • Total Committers: 11
  • Avg Commits per committer: 23.182
  • Development Distribution Score (DDS): 0.443
Top Committers
Name Email Commits
Henry Schreiner H****I@g****m 142
Henry Schreiner h****i@g****m 82
pre-commit-ci[bot] 6****]@u****m 15
dependabot[bot] 4****]@u****m 7
Angus Hollands g****5@g****m 3
Cristian Le c****e@m****e 1
Ben Greiner c****e@b****e 1
Max Bachmann k****t@m****e 1
Cristian Le g****b@l****e 1
Lukas Burgholzer b****r@m****m 1
Jinzhe Zeng j****g@r****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 317
  • Total pull requests: 774
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 7 days
  • Total issue authors: 132
  • Total pull request authors: 56
  • Average comments per issue: 3.57
  • Average comments per pull request: 1.21
  • Merged pull requests: 664
  • Bot issues: 19
  • Bot pull requests: 135
Past Year
  • Issues: 103
  • Pull requests: 248
  • Average time to close issues: 5 days
  • Average time to close pull requests: 5 days
  • Issue authors: 68
  • Pull request authors: 25
  • Average comments per issue: 2.81
  • Average comments per pull request: 0.75
  • Merged pull requests: 198
  • Bot issues: 4
  • Bot pull requests: 42
Top Authors
Issue Authors
  • henryiii (40)
  • LecrisUT (40)
  • packit-as-a-service[bot] (19)
  • vyasr (11)
  • mgorny (7)
  • petrasvestartas (6)
  • zerothi (6)
  • njzjz (5)
  • MuellerSeb (5)
  • dmitry-kabanov (4)
  • ChrisBarker-NOAA (4)
  • alexreinking (4)
  • yurivict (4)
  • planetmarshall (4)
  • mcleantom (3)
Pull Request Authors
  • henryiii (433)
  • LecrisUT (89)
  • pre-commit-ci[bot] (85)
  • dependabot[bot] (54)
  • jcfr (13)
  • vyasr (13)
  • thewtex (8)
  • alexreinking (4)
  • eirrgang (3)
  • stubbiali (3)
  • KyleFromNVIDIA (3)
  • njzjz (3)
  • 0xTowel (3)
  • mayeut (3)
  • burgholzer (2)
Top Labels
Issue Labels
question (3) enhancement (2) documentation (2) near-term (2) good first issue (1) bug (1)
Pull Request Labels
dependencies (54) github_actions (8) needs-backport (2) bug (1)

Packages

  • Total packages: 9
  • Total downloads: unknown
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 93
  • Total maintainers: 2
alpine-edge: py3-scikit-build-core-pyc

Precompiled Python bytecode for py3-scikit-build-core

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 7.2%
Dependent packages count: 14.3%
Maintainers (1)
Last synced: 6 months ago
alpine-edge: py3-scikit-build-core

Build backend for Python that uses CMake to build extension modules

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 7.2%
Dependent packages count: 14.3%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/scikit-build/scikit-build-core
  • Versions: 58
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 4.3%
Forks count: 4.5%
Average: 7.3%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 6 months ago
spack.io: py-scikit-build-core

scikit-build-core is a doubly improved build system generator for CPython C/C++/Fortran/Cython extensions. It features several improvements over the classic scikit-build build system generator.

  • Versions: 9
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 22.2%
Forks count: 25.0%
Average: 26.1%
Dependent packages count: 57.3%
Maintainers (1)
Last synced: 6 months ago
anaconda.org: scikit-build-core

Scikit-build-core is a ground-up rewrite of the classic Scikit-build, a bridge between Python package build systems and CMake, the most popular compiled language build system.

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Stargazers count: 42.6%
Forks count: 44.6%
Average: 47.4%
Dependent packages count: 51.2%
Dependent repos count: 51.4%
Last synced: 6 months ago
alpine-v3.21: py3-scikit-build-core-pyc

Precompiled Python bytecode for py3-scikit-build-core

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.22: py3-scikit-build-core-pyc

Precompiled Python bytecode for py3-scikit-build-core

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.22: py3-scikit-build-core

Build backend for Python that uses CMake to build extension modules

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.21: py3-scikit-build-core

Build backend for Python that uses CMake to build extension modules

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/cd.yml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • pypa/gh-action-pypi-publish v1.6.4 composite
.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3.1.1 composite
  • cygwin/cygwin-install-action v3 composite
  • hynek/build-and-inspect-python-package v1 composite
  • jwlawson/actions-setup-cmake v1.13 composite
  • msys2/setup-msys2 v2 composite
  • pre-commit/action v3.0.0 composite
  • re-actors/alls-green release/v1 composite
docs/examples/downstream/nanobind_example/pyproject.toml pypi
docs/examples/downstream/pybind11_example/pyproject.toml pypi
docs/examples/getting_started/abi3/pyproject.toml pypi
docs/examples/getting_started/c/pyproject.toml pypi
docs/examples/getting_started/cython/pyproject.toml pypi
docs/examples/getting_started/fortran/pyproject.toml pypi
  • numpy *
docs/examples/getting_started/nanobind/pyproject.toml pypi
docs/examples/getting_started/pybind11/pyproject.toml pypi
docs/examples/getting_started/swig/pyproject.toml pypi
pyproject.toml pypi
  • exceptiongroup python_version<'3.11'
  • importlib-metadata python_version<'3.8'
  • importlib-resources >=1.3; python_version<'3.9'
  • packaging >=20.9
  • tomli >=1.1; python_version<'3.11'
  • typing-extensions >=3.10.0; python_version<'3.8'
tests/packages/abi3_pyproject_ext/pyproject.toml pypi
tests/packages/abi3_setuptools_ext/pyproject.toml pypi
tests/packages/abi3_setuptools_ext/setup.py pypi
tests/packages/custom_cmake/extern/pyproject.toml pypi
tests/packages/custom_cmake/pyproject.toml pypi
tests/packages/dynamic_metadata/pyproject.toml pypi
tests/packages/filepath_pure/pyproject.toml pypi
tests/packages/fortran_example/pyproject.toml pypi
  • numpy *
tests/packages/mixed_setuptools/pyproject.toml pypi
tests/packages/mixed_setuptools/setup.py pypi
tests/packages/sdist_config/pyproject.toml pypi
tests/packages/simple_pyproject_ext/pyproject.toml pypi
tests/packages/simple_pyproject_source_dir/pyproject.toml pypi
tests/packages/simple_setuptools_ext/pyproject.toml pypi
tests/packages/simple_setuptools_ext/setup.py pypi
tests/packages/simplest_c/pyproject.toml pypi