Modern, PEP 517 compliant build backend for building Python packages with
Project description
py-build-cmake
Modern, PEP 517 compliant build backend for building Python packages with extensions built using CMake.
Features
- Build C, C++ or Fortran extension modules for Python using CMake
- Declarative configuration using
pyproject.toml
(PEP 621), compatible with flit - Editable/development installations for Python modules (PEP 660)
- Compatible with pybind11
- Generate stubs for type checking and autocompletion
- Customizable CMake configuration, build and installation options
- Support for multiple installation configurations and components
- Cross-compilation support
- No dependency on setuptools
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 following command to get the documentation for all supported options:
python -m py_build_cmake.help
Usage
If you don't have one already, add a pyproject.toml
configuration file to your
project's repository. Specify the metadata required by PEP 621,
and tell py-build-cmake how to build your project. For example:
[project] # Project metadata
name = "example-project"
readme = "README.md"
requires-python = ">=3.8"
license = { "file" = "LICENSE" }
authors = [{ "name" = "Pieter P", "email" = "pieter.p.dev@outlook.com" }]
keywords = ["some", "keywords"]
classifiers = ["Topic :: Scientific/Engineering"]
urls = { "Documentation" = "https://tttapa.github.io/py-build-cmake" }
dependencies = ["numpy"]
dynamic = ["version", "description"]
[build-system] # How pip and other frontends should build this project
requires = ["py-build-cmake", "mypy"]
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 install and/or build the package.
Build sdist and wheel packages you can upload to PyPI:
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
For example usage, see the examples/minimal
and examples/pybind11-project
example projects.
Planned features
-
Entry point support - Namespace package support (PEP 420)
- Doxygen and Sphinx support
-
macOS support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for py_build_cmake-0.0.7-py310-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26f3ada0ade9857db37392da8410b563df27733a28cc3fc663dd4705f6caf49a |
|
MD5 | fe1df6ee6fcf5539b31a3955d81505ec |
|
BLAKE2b-256 | 7c214a1adef3a283ad9018ea7fdb26920804cbcd4ae4eb1a031872f05434dd12 |
Hashes for py_build_cmake-0.0.7-py39-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6776f46dc96cb5f215f847e6d0dff4c0d4d6ee65383dea70826e0671331ea712 |
|
MD5 | 3382e78f35853d36eec6dd3666d8b686 |
|
BLAKE2b-256 | 90a54e21c67113b507d076680b3e396b70cb722389c30926ea6092acc0dd6e23 |
Hashes for py_build_cmake-0.0.7-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8ecdd32341bc25be46dcc1787e34957fa7dd5ce9ef18da2f61339bf5476241c |
|
MD5 | e17490387577e583b81ebc4d40008768 |
|
BLAKE2b-256 | a1d8cce6aaa70828565fde7880f0b8b224260089abc503cb21d06dcb6c78b40f |