Metadata-Version: 2.4
Name: conan-py-build
Version: 0.4.2
Summary: A minimal PEP 517 compliant build backend that uses Conan to build Python C/C++ extensions
Author-email: The Conan team <conan@jfrog.com>
License: MIT
Project-URL: Homepage, https://github.com/conan-io/conan-py-build
Project-URL: Documentation, https://conan-py-build.conan.io
Project-URL: Issues, https://github.com/conan-io/conan-py-build/issues
Keywords: build,backend,pep517,conan,c++,cmake
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: conan>=2.5
Requires-Dist: distlib>=0.3.0
Requires-Dist: packaging
Requires-Dist: pyproject-metadata
Requires-Dist: tomli>=1.2.3; python_version < "3.11"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: setuptools-scm; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
Requires-Dist: mkdocs-material; extra == "docs"
Dynamic: license-file

# conan-py-build

A [PEP 517](https://peps.python.org/pep-0517/) build backend that uses
[Conan](https://conan.io) to build Python C/C++ extensions.

**[Documentation](https://conan-py-build.conan.io)** ·
[PyPI](https://pypi.org/project/conan-py-build/) ·
[Examples](examples/)

## Install

```bash
pip install conan-py-build
```

## Quick start

> [!NOTE] The steps below use CMake, but the backend is build-system agnostic —
> it works with anything Conan can drive. For a Meson version, see
> [basic-meson-pybind11](examples/basic-meson-pybind11/).

1. Set `conan-py-build` as your build backend:

```toml
[build-system]
requires = ["conan-py-build"]
build-backend = "conan_py_build.build"

[project]
name = "mypackage"
version = "0.1.0"
```

2. Add a `conanfile.py` with your C++ dependencies:

```python
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout

class MyPackageConan(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeToolchain", "CMakeDeps"

    def layout(self):
        cmake_layout(self)

    def requirements(self):
        self.requires("fmt/12.1.0")

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package(self):
        cmake = CMake(self)
        cmake.install()
```

3. Your `CMakeLists.txt` must install the extension
   into the package directory so it ends up in the wheel:

```cmake
install(TARGETS _core DESTINATION mypackage)
```

4. Build:

```bash
pip wheel . -w dist/ -vvv
```

See the [documentation](https://conan-py-build.conan.io)
for the full getting started guide, configuration, profiles,
dynamic versioning, and more.

## Examples

See the [examples/](examples/) directory:

- **[basic](examples/basic/)** — `fmt` extension, recipe via `conanfile-path`
- **[basic-pybind11](examples/basic-pybind11/)** — pybind11 + `fmt`, dynamic version, PEP 639
- **[basic-meson-pybind11](examples/basic-meson-pybind11/)** — pybind11 + `fmt` built with Meson instead of CMake
- **[basic-nanobind](examples/basic-nanobind/)** — nanobind + `fmt`, `extra-profile` for C++17
- **[external-sources](examples/external-sources/)** — pybind11, C++ dep fetched in `source()`
- **[cibw-example](examples/cibw-example/)** — pybind11 + [cibuildwheel](https://cibuildwheel.pypa.io/)

## License

MIT — see [LICENSE](LICENSE).
