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
- OSX 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.2-py310-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc77a7e57ab4d4724d2bdcb7deeba1f62d7902987cc13cf5f29f073292411df2 |
|
MD5 | 617a45d0f0dae6e4ebcef02af1cd5de4 |
|
BLAKE2b-256 | 9796285e084edfbff048fc9debd3dc049bb2e91ca237a6075ca497a655017d40 |
Hashes for py_build_cmake-0.0.2-py39-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bd1ef3b1af910fe5859e56457adec494c6cbf5e185323c668155b09f825431a |
|
MD5 | 38d6e5c2f4d12cb13472ef8ef5509433 |
|
BLAKE2b-256 | c6cadf1a9bafc9965fd8a7ab92c5f92ad6ec99ec9760266db3883c14dd15d692 |
Hashes for py_build_cmake-0.0.2-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6215e6819d0ae681ce7deaedea068327c8228a52577bffed3bc7e30d8525d9cf |
|
MD5 | 88d586e8f2cfca06acc03c7fef022db9 |
|
BLAKE2b-256 | 445029cc3768327b43f9530cec4c990ec2712cb5984efc3f22944165132eb1a5 |