With the popularity and success of the python programming language, it has become increasingly important for researches to be able to make software developments available to the python eco-system by means of extension packages. To this end, the [Pybind11](https://github.com/pybind/pybind11) library provides a convenient approach to generate python bindings of existing C++ code. In this context, the [sciki-build](https://github.com/scikit-build/scikit-build) project can be used to bridge python's `setuptools` with [CMake](https://cmake.org/). As a resuls, CMake's features such as, e.g., choice of build-generators, dependency management or cross-compilation, can easily be exploited from within the installation process of the developed python extension.
With the popularity and success of the python programming language, it has become increasingly important for researches to be able to make software developments available to the python eco-system by means of extension packages. To this end, the [Pybind11](https://github.com/pybind/pybind11) library provides a convenient approach to generate python bindings for (existing) C++ code. In this context, the [sciki-build](https://github.com/scikit-build/scikit-build) project can be used to bridge python's `setuptools` with [CMake](https://cmake.org/). As a resuls, CMake's features such as, e.g., choice of build-generators, dependency management or cross-compilation, can easily be exploited from within the installation process of the developed python extension.
## Basic Usage
The basic usage of pybind11 in combindation with scikit-build will be demonstrated in the following using a 'hello-world' python extension that can be accessed [here](sebak/pybind11-hello-world).
The basic usage of pybind11 in combindation with scikit-build will be demonstrated in the following using a 'hello-world' python extension package that can be accessed [here](sebak/pybind11-hello-world).
## pybind11 hello-world
missing content
pybind11 is a header-only library that provides conversion from C++ types to Python. The following C++ file demonstrates its use
```c++
#include<iostream>
#include<pybind11/pybind11.h>
namespacepy=pybind11;
voidhello(){
std::cout<<"Hello, World!"<<std::endl;
}
PYBIND11_MODULE(_hello,m){
m.doc()="Package to say hi";
m.def("hello",&hello,"Prints \"Hello, World!\"");
}
```
In order for this example to be compiled, the pybind11 headers (as any other potential dependency) must be available. pybind11 can be installed in [several ways](https://pybind11.readthedocs.io/en/stable/installing.html) and it also natively support various [build systems](https://pybind11.readthedocs.io/en/stable/compiling.html#compiling). However using scikit-build provides a particulary easy approach which is shown in the following.