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.3-py310-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18c790dee6b3d3d0948f9cbb51816803b55709622cc8ffa13fdc181b2cce1cfa |
|
MD5 | 56130fb66d2139f4e2853e6250d3a937 |
|
BLAKE2b-256 | 958a76d5e982bb2b67662bc222d0d383b2628fac2a16f081ca702d44b3eb184a |
Hashes for py_build_cmake-0.0.3-py39-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d0bb444ec73a04248dd8bb84e0978f30866e85ad0eeee5b0ccf45a6b6fc24d3 |
|
MD5 | 7e1c2db196fc9bb5289c41b5d32cf66b |
|
BLAKE2b-256 | caed3133962e10793fbb02f66704084d3cf323ebaeccbba27cc6708688b27106 |
Hashes for py_build_cmake-0.0.3-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b70f9f1f8e75c121c3236ef50666e45d51688dc02697521a4a874f3aef07c55f |
|
MD5 | 1af1a09851418d6cbec230c084c3b038 |
|
BLAKE2b-256 | a8110dcbe436f8dc3e254015385687c9a72a73b32208db86b13c1f5914d44a54 |