Skip to main content

py-build-cmake
py-build-cmake

Python Wheel Documentation PyPI - Downloads

A modern, PEP 517 compliant build backend for creating Python packages with extensions built using CMake.

Features

  • Building and packaging C, C++ or Fortran extension modules for Python using CMake
  • Declarative configuration using pyproject.toml (PEP 621)
  • Editable/development installations for Python modules (PEP 660)
  • Easy integration with pybind11, nanobind and SWIG, with stable ABI support
  • Stub generation for type checking and autocompletion
  • Customizable CMake configuration, build, and installation options
  • Support for installation of multiple configurations and components, across different Wheel packages
  • First-class cross-compilation support
  • Reproducible Wheels and source distributions
  • No dependency on setuptools
  • Compatible with cibuildwheel for building Wheels

Installation

The py-build-cmake package is available on PyPI:

pip install py-build-cmake

Documentation

The documentation can be found on https://tttapa.github.io/py-build-cmake.

The format of the configuration file is explained in Config.md.

Alternatively, use the command-line interface to get the documentation for all supported options:

py-build-cmake config format

To get started quickly, have a look at the following section and the README in examples/minimal, which goes over the project structure and the configuration files you'll need.

Usage

If you don't have one already, add a pyproject.toml configuration file to your project's repository. Specify the mandatory project metadata (PyPA: Declaring project metadata), and tell py-build-cmake how to build your CMake project. For example:

[project] # Project metadata
name = "example-project"
requires-python = ">=3.8"
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
dependencies = ["numpy"]
dynamic = ["version", "description"]

[build-system] # How pip and other frontends should build this project
requires = ["py-build-cmake~=0.5.1"]
build-backend = "py_build_cmake.build"

[tool.py-build-cmake.module] # Where to find the Python module to package
directory = "src-python"

[tool.py-build-cmake.sdist] # What to include in source distributions
include = ["CMakeLists.txt", "src/*"]

[tool.py-build-cmake.cmake] # How to build the CMake project
build_type = "RelWithDebInfo"
source_path = "src"
build_args = ["-j"]
install_components = ["python_modules"]

[tool.py-build-cmake.stubgen] # Whether and how to generate typed stub files

The README of examples/minimal describes this configuration file in much more detail.

Then use pip, build or another PEP 517 compatible frontend to build and/or install the package.

Build sdist and wheel packages you can upload to PyPI:

python -m pip install -U build
python -m build . # find the sdist and wheel file in the 'dist' folder

Install the package in the current environment:

pip install .    # normal installation
pip install -e . # editable installation

Examples

As an introduction to py-build-cmake, see examples/minimal for a detailed overview of the configuration files and the directory structure, using a very simple Python module as an example.
For a more advanced, real-world example, see examples/pybind11-project and examples/nanobind-project.
Alternatively, SWIG can also be used instead of pybind11 or nanobind, as demonstrated in examples/swig-project.
If you are interested in packaging C/C++/Fortran programs using py-build-cmake, have a look at examples/minimal-program.
See the examples folder for a full list of examples.

A full example that uses the Conan package manager for C++ dependencies, and that uses GitHub Actions to deploy the Wheel packages built by py-build-cmake to PyPI can be found in tttapa/py-build-cmake-example.

Projects using py-build-cmake

If you need more examples, you can look at the following projects using py-build-cmake as their Python build backend:

  • scikit-build-core: alternative CMake build backend, successor of scikit-build
  • meson-python: Meson build backend
  • flit: pure-Python packaging tool and build backend
  • hatchling: build backend of the Hatch project manager, supports build hooks
  • poetry-core: pure-Python build backend for the Poetry package manager
  • crossenv: tool to trick setuptools into cross-compiling by monkey patching the sysconfig and distutils modules

Metadata

Release files for py-build-cmake 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-build-cmake 0.5.1
File Size Uploaded Provenance Actions
py_build_cmake-0.5.1.tar.gz 75.2 kB With provenance Details for py_build_cmake-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-build-cmake 0.5.1
File Interpreter ABI Platform Actions
py_build_cmake-0.5.1-py3-none-any.whl Python 3 none any Details for py_build_cmake-0.5.1-py3-none-any.whl

Total release size: 172.5 kB

Release files / py_build_cmake-0.5.1.tar.gz

Download URL py_build_cmake-0.5.1.tar.gz
Size 75.2 kB
Tags Source
SHA-256 checksum
How to use checksums
31a83b12fcc5fddee4d84f36c2d9a2954eb1a7907f5a9cb06f439232859ce513
BLAKE2b-256 checksum
How to use checksums
6d556334f07a7772620130feb1300db0ff39f5c9385e3e6a94090d800353e3f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.

Transparency log

Release files / py_build_cmake-0.5.1-py3-none-any.whl

Download URL py_build_cmake-0.5.1-py3-none-any.whl
Size 97.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78d5f2117169644f44d0d99d3a5e97fa9dc0b1458d8eccb96c46b5e15fecb8e7
BLAKE2b-256 checksum
How to use checksums
152558eb111c349f631f5a664c293dffdd6036197e70f818c2e198ae32e116ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.

Transparency log

Security for py-build-cmake 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for py_build_cmake-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page