Skip to content

Code for lighting talk about how pybind11 enables the exposure of a simple C++ API to Python as a module

Notifications You must be signed in to change notification settings

the-risk-taker/meson-cmake-pybind11-cpp-python

Repository files navigation

Meson/CMake ➕ C++ ➕ pybind11 ➕ Python

About

A combination of C++ and Python to expose an simple API written in C++ to Python as a module. Achieved through the use of pybind11, a lightweight header-only library that facilitates the seamless integration of C++11 code with Python.

Dependencies

  • Meson/CMake
  • pybind11
    • for Meson and manual building: pip install pybind11,
    • for CMake: git submodule update --init --recursive --remote
  • C++11 compatible compiler (Clang or GCC on Linux, MSVC on Windows)

Building

Manually

c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) <source.cpp> -o <module_name>$(python3-config --extension-suffix)

Meson

meson setup build-meson
meson compile -C build-meson
python3 main.py build-meson

CMake

cmake -S . -B build-cmake
cmake --build build-cmake
python3 main.py build-cmake

Useful links

About

Code for lighting talk about how pybind11 enables the exposure of a simple C++ API to Python as a module

Topics

Resources

Stars

Watchers

Forks