My experiments with C++ extensions for python using pybind11.
- Python 3.8–3.10 with
pip(version 22+ recommended for editable installs) - CMake (>= 3.16)
- Armadillo C++ linear algebra library — install via your package manager:
- macOS:
brew install armadillo - Ubuntu/Debian:
sudo apt install libarmadillo-dev
- macOS:
- A C++17 compiler (e.g. AppleClang, GCC, MSVC)
-
Initialize git submodules (required for carma):
git submodule update --init --recursive
-
Install the project in editable mode:
pip install -e ".[dev]"
-
Initialize git submodules (required for carma):
git submodule update --init --recursive
-
Install Python build dependencies:
pip install "pybind11[global]>=2.6.0" "numpy>=1.14"
-
Build with cmake:
mkdir build cd build cmake .. -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") -DCMAKE_INSTALL_PREFIX:PATH=.. make install
Note:
-DCMAKE_INSTALL_PREFIX:PATHis set to..to make the path in the install command in the CMakeLists.txt file relative to the location of the file.
- use scikit-build-core to compile the C++ modules
- CI pipelines for tests
- Update Makefile
- remove sphinx docs (won't ever publish them for this project)
- Check how to automate the Armadillo installation either as a github submodule or using cmake's FetchContent like in carma