Skip to content

ltsaprounis/python-cpp-experiments

Repository files navigation

Python-cpp-experiments

My experiments with C++ extensions for python using pybind11.

python_braces

 

Prerequisites

  • 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
  • A C++17 compiler (e.g. AppleClang, GCC, MSVC)

Build

Option 1: scikit-build-core (recommended)

  1. Initialize git submodules (required for carma):

    git submodule update --init --recursive
  2. Install the project in editable mode:

    pip install -e ".[dev]"

Option 2: Manual cmake build

  1. Initialize git submodules (required for carma):

    git submodule update --init --recursive
  2. Install Python build dependencies:

    pip install "pybind11[global]>=2.6.0" "numpy>=1.14"
  3. 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:PATH is set to .. to make the path in the install command in the CMakeLists.txt file relative to the location of the file.

TODOs:

  • 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

About

My experiments with C++ extensions for python using pybind11.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors