Package: py-build-cmake
py-build-cmakeModern,PEP 517compliant build
backend for creating Python packages with extensions built using CMake.FeaturesBuilding and packaging C, C++ or Fortran extension modules for Python using CMakeDeclarative configuration usingpyproject.toml(PEP 621), compatible withflitEditable/development installations for Python modules (PEP 660)Compatible withpybind11andnanobindStub generation for type checking and autocompletionCustomizable CMake configuration, build and installation optionsSupport for multiple installation configurations and componentsCross-compilation supportNo dependency onsetuptoolsCompatible withcibuildwheelfor building WheelsInstallationThe py-build-cmake package is available onPyPI:pipinstallpy-build-cmakeDocumentationThe documentation can be found onhttps://tttapa.github.io/py-build-cmake.The format of the configuration file is explained inConfig.md.Alternatively, use thecommand-line interfaceto get the documentation for all supported options:py-build-cmakeconfigformatUsageIf you don't have one already, add apyproject.tomlconfiguration file to your
project's repository. Specify the metadata required byPEP 621,
and tell py-build-cmake how to build your project. For example:[project]# Project metadataname="example-project"readme="README.md"requires-python=">=3.7"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 projectrequires=["py-build-cmake~=0.1.8"]build-backend="py_build_cmake.build"[tool.py-build-cmake.module]# Where to find the Python module to packagedirectory="src-python"[tool.py-build-cmake.sdist]# What to include in source distributionsinclude=["CMakeLists.txt","src/*"][tool.py-build-cmake.cmake]# How to build the CMake projectbuild_type="RelWithDebInfo"source_path="src"build_args=["-j"]install_components=["python_modules"][tool.py-build-cmake.stubgen]# Whether and how to generate typed stub filesThe README ofexamples/minimaldescribes this configuration file in much more detail.Then usepip,buildor another PEP 517 compatible frontend to build and/or install the package.Build sdist and wheel packages you can upload to PyPI:python-mpipinstall-Ubuild
python-mbuild.# find the sdist and wheel file in the 'dist' folderInstall the package in the current environment:pipinstall.# normal installationpipinstall-e.# editable installationExamplesAs an introduction to py-build-cmake, seeexamples/minimalfor 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, seeexamples/pybind11-projectandexamples/nanobind-project.If you are interested in packaging C/C++/Fortran programs using py-build-cmake,
have a look atexamples/minimal-program.Projects using py-build-cmakeIf you need more examples, you can look at the following projects using
py-build-cmake as their Python build backend:alpaqaQPALMPlanned featuresmacOS supportEntry point supportNamespace package support (PEP 420)Doxygen and Sphinx support