py-build-cmake


Namepy-build-cmake JSON
Version 0.3.3 PyPI version JSON
download
home_pageNone
SummaryModern, PEP 517 compliant build backend for creating Python packages with
upload_time2024-12-07 16:05:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2022 Pieter P Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pep517 cmake
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![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)
[![Documentation](https://img.shields.io/badge/Documentation-main-blue)](https://tttapa.github.io/py-build-cmake)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/py-build-cmake?label=PyPI)](https://pypi.org/project/py-build-cmake)

# py-build-cmake

Modern, [PEP 517](https://www.python.org/dev/peps/pep-0517/) compliant build
backend for creating Python packages with extensions built using CMake.

## Features

 - Building and packaging C, C++ or Fortran extension modules for Python using CMake
 - Declarative configuration using `pyproject.toml` ([PEP 621](https://www.python.org/dev/peps/pep-0621/))
 - Editable/development installations for Python modules ([PEP 660](https://www.python.org/dev/peps/pep-0660/))
 - 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
 - Stub generation for type checking and autocompletion
 - Customizable CMake configuration, build, and installation options
 - Support for installation of multiple configurations and components, across different Wheel packages
 - First-class cross-compilation support
 - Reproducible Wheels and source distributions
 - No dependency on [setuptools](https://github.com/pypa/setuptools)
 - Compatible with [cibuildwheel](https://github.com/pypa/cibuildwheel) for building Wheels

## Installation

The py-build-cmake package is available on
[PyPI](https://pypi.org/project/py-build-cmake/):

```sh
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](https://tttapa.github.io/py-build-cmake/Config.html).

Alternatively, use the [command-line interface](https://tttapa.github.io/py-build-cmake/CLI.html)
to get the documentation for all supported options:
```sh
py-build-cmake config format
```

To get started quickly, have a look at the following section and the README in
[`examples/minimal`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal),
which goes over the project structure and the configuration files you'll need.

## Usage

If you don't have one already, add a `pyproject.toml` configuration file to your
project's repository. Specify the mandatory project metadata ([PyPA: Declaring project metadata](https://packaging.python.org/en/latest/specifications/declaring-project-metadata)),
and tell py-build-cmake how to build your CMake project. For example:

```toml
[project] # Project metadata
name = "example-project"
requires-python = ">=3.7"
readme = "README.md"
license = { "file" = "LICENSE" }
dependencies = ["numpy"]
dynamic = ["version", "description"]

[build-system] # How pip and other frontends should build this project
requires = ["py-build-cmake~=0.3.3"]
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`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal)
describes this configuration file in much more detail.

Then use [`pip`](https://github.com/pypa/pip), [`build`](https://github.com/pypa/build)
or another PEP 517 compatible frontend to build and/or install the package.

Build sdist and wheel packages you can upload to PyPI:
```sh
python -m pip install -U build
python -m build . # find the sdist and wheel file in the 'dist' folder
```

Install the package in the current environment:
```sh
pip install .    # normal installation
pip install -e . # editable installation
```

## Examples

As an introduction to py-build-cmake, see [`examples/minimal`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal)
for 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, see [`examples/pybind11-project`](https://github.com/tttapa/py-build-cmake/tree/main/examples/pybind11-project)
and [`examples/nanobind-project`](https://github.com/tttapa/py-build-cmake/tree/main/examples/nanobind-project).  
Alternatively, SWIG can also be used instead of pybind11 or nanobind, as
demonstrated in [`examples/swig-project`](https://github.com/tttapa/py-build-cmake/tree/main/examples/swig-project).  
If you are interested in packaging C/C++/Fortran programs using py-build-cmake,
have a look at [`examples/minimal-program`](https://github.com/tttapa/py-build-cmake/tree/main/examples/minimal-program).  
See the [`examples`](https://github.com/tttapa/py-build-cmake/tree/main/examples) folder for a full list of examples.

A full example that uses the Conan package manager for C++ dependencies, and
that uses GitHub Actions to deploy the Wheel packages built by py-build-cmake
to PyPI can be found in [tttapa/py-build-cmake-example](https://github.com/tttapa/py-build-cmake-example).

## Projects using py-build-cmake

If you need more examples, you can look at the following projects using
py-build-cmake as their Python build backend:

- [alpaqa](https://github.com/kul-optec/alpaqa/tree/develop)
- [QPALM](https://github.com/kul-optec/QPALM)

## Alternatives and related tools

- [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)
- [meson-python](https://github.com/mesonbuild/meson-python): Meson build backend
- [flit](https://github.com/pypa/flit): pure-Python packaging tool and build backend
- [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
- [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
- [crossenv](https://github.com/benfogle/crossenv): tool to trick `setuptools` into cross-compiling by monkey patching the `sysconfig` and `distutils` modules

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-build-cmake",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "pep517 cmake",
    "author": null,
    "author_email": "Pieter P <pieter.p.dev@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/45/f1/39090108be50e3a8845a94f2e02566b277e4af77671d1c844440eda3814a/py_build_cmake-0.3.3.tar.gz",
    "platform": null,
    "description": "[![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# py-build-cmake\n\nModern, [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 <https://tttapa.github.io/py-build-cmake>.\n\nThe format of the configuration file is explained in\n[Config.md](https://tttapa.github.io/py-build-cmake/Config.html).\n\nAlternatively, use the [command-line interface](https://tttapa.github.io/py-build-cmake/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 = \">=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.3.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",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Pieter P  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Modern, PEP 517 compliant build backend for creating Python packages with",
    "version": "0.3.3",
    "project_urls": {
        "Documentation": "https://tttapa.github.io/py-build-cmake",
        "Source": "https://github.com/tttapa/py-build-cmake",
        "Tracker": "https://github.com/tttapa/py-build-cmake/issues"
    },
    "split_keywords": [
        "pep517",
        "cmake"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65085704c19c7394f8c0a2638b3f27e6c5be92167d15fb8139f8779947657518",
                "md5": "d33ef40c353089cc504ca2e675249c23",
                "sha256": "eef87a43035aed6c4e38364a5e6e5cb5fee14fb28ba3f973eca58ddfe1ed9afa"
            },
            "downloads": -1,
            "filename": "py_build_cmake-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d33ef40c353089cc504ca2e675249c23",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 86509,
            "upload_time": "2024-12-07T16:05:22",
            "upload_time_iso_8601": "2024-12-07T16:05:22.808749Z",
            "url": "https://files.pythonhosted.org/packages/65/08/5704c19c7394f8c0a2638b3f27e6c5be92167d15fb8139f8779947657518/py_build_cmake-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45f139090108be50e3a8845a94f2e02566b277e4af77671d1c844440eda3814a",
                "md5": "efc05ae876b512affadde6c9434e50f7",
                "sha256": "9434d2ac113f9cf1e5f16e8cf01e78a4059d1198794d4c04602087583e34c517"
            },
            "downloads": -1,
            "filename": "py_build_cmake-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "efc05ae876b512affadde6c9434e50f7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 66993,
            "upload_time": "2024-12-07T16:05:24",
            "upload_time_iso_8601": "2024-12-07T16:05:24.371934Z",
            "url": "https://files.pythonhosted.org/packages/45/f1/39090108be50e3a8845a94f2e02566b277e4af77671d1c844440eda3814a/py_build_cmake-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-07 16:05:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tttapa",
    "github_project": "py-build-cmake",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "py-build-cmake"
}
        
Elapsed time: 4.54941s