{"id":18968865,"url":"https://github.com/tttapa/py-build-cmake","last_synced_at":"2025-04-13T12:08:38.440Z","repository":{"id":39733368,"uuid":"450669935","full_name":"tttapa/py-build-cmake","owner":"tttapa","description":"Modern, PEP 517 compliant build backend for creating Python packages with extensions built using CMake.","archived":false,"fork":false,"pushed_at":"2025-04-07T18:55:39.000Z","size":2682,"stargazers_count":58,"open_issues_count":8,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-13T12:08:21.152Z","etag":null,"topics":["build","cmake","nanobind","pep517","pybind11","python"],"latest_commit_sha":null,"homepage":"https://tttapa.github.io/py-build-cmake/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tttapa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-21T23:34:42.000Z","updated_at":"2025-04-11T11:14:15.000Z","dependencies_parsed_at":"2022-07-21T04:49:06.044Z","dependency_job_id":"0eaa3c2a-c71a-4556-9d80-b1c0d421937a","html_url":"https://github.com/tttapa/py-build-cmake","commit_stats":{"total_commits":151,"total_committers":1,"mean_commits":151.0,"dds":0.0,"last_synced_commit":"361d39496ac9c3121dfd2468402f0b2a889ccb5e"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tttapa%2Fpy-build-cmake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tttapa%2Fpy-build-cmake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tttapa%2Fpy-build-cmake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tttapa%2Fpy-build-cmake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tttapa","download_url":"https://codeload.github.com/tttapa/py-build-cmake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710431,"owners_count":21149190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","cmake","nanobind","pep517","pybind11","python"],"created_at":"2024-11-08T14:48:41.539Z","updated_at":"2025-04-13T12:08:38.431Z","avatar_url":"https://github.com/tttapa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003cimg src=\"https://tttapa.github.io/py-build-cmake/_static/py-build-cmake-logo.svg\" alt=\"py-build-cmake\" width=\"64\"/\u003e \u003cbr\u003epy-build-cmake\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Python Wheel](https://github.com/tttapa/py-build-cmake/actions/workflows/wheel.yml/badge.svg)](https://github.com/tttapa/py-build-cmake/actions/workflows/wheel.yml)\n[![Documentation](https://img.shields.io/badge/Documentation-main-blue)](https://tttapa.github.io/py-build-cmake)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/py-build-cmake?label=PyPI)](https://pypi.org/project/py-build-cmake)\n\n\u003c/div\u003e\n\nA modern, [PEP 517](https://www.python.org/dev/peps/pep-0517/) compliant build\nbackend for creating Python packages with extensions built using CMake.\n\n## Features\n\n - Building and packaging C, C++ or Fortran extension modules for Python using CMake\n - Declarative configuration using `pyproject.toml` ([PEP 621](https://www.python.org/dev/peps/pep-0621/))\n - Editable/development installations for Python modules ([PEP 660](https://www.python.org/dev/peps/pep-0660/))\n - Easy integration with [pybind11](https://github.com/pybind/pybind11), [nanobind](https://github.com/wjakob/nanobind) and [SWIG](https://github.com/swig/swig), with stable ABI support\n - Stub generation for type checking and autocompletion\n - Customizable CMake configuration, build, and installation options\n - Support for installation of multiple configurations and components, across different Wheel packages\n - First-class cross-compilation support\n - Reproducible Wheels and source distributions\n - No dependency on [setuptools](https://github.com/pypa/setuptools)\n - Compatible with [cibuildwheel](https://github.com/pypa/cibuildwheel) for building Wheels\n\n## Installation\n\nThe py-build-cmake package is available on\n[PyPI](https://pypi.org/project/py-build-cmake/):\n\n```sh\npip install py-build-cmake\n```\n\n## Documentation\n\nThe documentation can be found on **\u003chttps://tttapa.github.io/py-build-cmake\u003e**.\n\nThe format of the configuration file is explained in\n[Config.md](https://tttapa.github.io/py-build-cmake/reference/config.html).\n\nAlternatively, use the [command-line interface](https://tttapa.github.io/py-build-cmake/usage/cli.html)\nto get the documentation for all supported options:\n```sh\npy-build-cmake config format\n```\n\nTo get started quickly, have a look at the following section and the README in\n[`examples/minimal`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal),\nwhich goes over the project structure and the configuration files you'll need.\n\n## Usage\n\nIf you don't have one already, add a `pyproject.toml` configuration file to your\nproject's repository. Specify the mandatory project metadata ([PyPA: Declaring project metadata](https://packaging.python.org/en/latest/specifications/declaring-project-metadata)),\nand tell py-build-cmake how to build your CMake project. For example:\n\n```toml\n[project] # Project metadata\nname = \"example-project\"\nrequires-python = \"\u003e=3.7\"\nreadme = \"README.md\"\nlicense = { \"file\" = \"LICENSE\" }\ndependencies = [\"numpy\"]\ndynamic = [\"version\", \"description\"]\n\n[build-system] # How pip and other frontends should build this project\nrequires = [\"py-build-cmake~=0.4.3\"]\nbuild-backend = \"py_build_cmake.build\"\n\n[tool.py-build-cmake.module] # Where to find the Python module to package\ndirectory = \"src-python\"\n\n[tool.py-build-cmake.sdist] # What to include in source distributions\ninclude = [\"CMakeLists.txt\", \"src/*\"]\n\n[tool.py-build-cmake.cmake] # How to build the CMake project\nbuild_type = \"RelWithDebInfo\"\nsource_path = \"src\"\nbuild_args = [\"-j\"]\ninstall_components = [\"python_modules\"]\n\n[tool.py-build-cmake.stubgen] # Whether and how to generate typed stub files\n```\nThe README of [`examples/minimal`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal)\ndescribes this configuration file in much more detail.\n\nThen use [`pip`](https://github.com/pypa/pip), [`build`](https://github.com/pypa/build)\nor another PEP 517 compatible frontend to build and/or install the package.\n\nBuild sdist and wheel packages you can upload to PyPI:\n```sh\npython -m pip install -U build\npython -m build . # find the sdist and wheel file in the 'dist' folder\n```\n\nInstall the package in the current environment:\n```sh\npip install .    # normal installation\npip install -e . # editable installation\n```\n\n## Examples\n\nAs an introduction to py-build-cmake, see [`examples/minimal`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal)\nfor a detailed overview of the configuration files and the directory structure,\nusing a very simple Python module as an example.  \nFor a more advanced, real-world example, see [`examples/pybind11-project`](https://github.com/tttapa/py-build-cmake/tree/main/examples/pybind11-project)\nand [`examples/nanobind-project`](https://github.com/tttapa/py-build-cmake/tree/main/examples/nanobind-project).  \nAlternatively, SWIG can also be used instead of pybind11 or nanobind, as\ndemonstrated in [`examples/swig-project`](https://github.com/tttapa/py-build-cmake/tree/main/examples/swig-project).  \nIf you are interested in packaging C/C++/Fortran programs using py-build-cmake,\nhave a look at [`examples/minimal-program`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal-program).  \nSee the [`examples`](https://github.com/tttapa/py-build-cmake/tree/main/examples) folder for a full list of examples.\n\nA full example that uses the Conan package manager for C++ dependencies, and\nthat uses GitHub Actions to deploy the Wheel packages built by py-build-cmake\nto PyPI can be found in [tttapa/py-build-cmake-example](https://github.com/tttapa/py-build-cmake-example).\n\n## Projects using py-build-cmake\n\nIf you need more examples, you can look at the following projects using\npy-build-cmake as their Python build backend:\n\n- [alpaqa](https://github.com/kul-optec/alpaqa/tree/develop)\n- [QPALM](https://github.com/kul-optec/QPALM)\n\n## Alternatives and related tools\n\n- [scikit-build-core](https://github.com/scikit-build/scikit-build-core): alternative CMake build backend, successor of [scikit-build](https://github.com/scikit-build/scikit-build)\n- [meson-python](https://github.com/mesonbuild/meson-python): Meson build backend\n- [flit](https://github.com/pypa/flit): pure-Python packaging tool and build backend\n- [hatchling](https://hatch.pypa.io/latest/config/build/#build-system): build backend of the [Hatch](https://hatch.pypa.io/latest/) project manager, supports build hooks\n- [poetry-core](https://python-poetry.org/docs/pyproject/#poetry-and-pep-517): pure-Python build backend for the [Poetry](https://python-poetry.org/) package manager\n- [crossenv](https://github.com/benfogle/crossenv): tool to trick `setuptools` into cross-compiling by monkey patching the `sysconfig` and `distutils` modules\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftttapa%2Fpy-build-cmake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftttapa%2Fpy-build-cmake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftttapa%2Fpy-build-cmake/lists"}