Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.16 KB

README.md

File metadata and controls

37 lines (27 loc) · 1.16 KB

embedding_python_in_cpp

an example project using pybind11 to embed python in a C++ executable. There are three basic parts:

  1. a C++ driver executable (driver.cpp)
  2. a small C++ library (src/mylib.cpp) that negociates between the driver executable and the python library
  3. a small jax / python library (mypythonlib.py)

requirements

this project uses jax, so install that first

build instructions

clone the project recursively

git clone https://github.com/samuelpmish/embedding_python_in_cpp.git --recursive

configure and build with CMake

cd embedding_python_in_cpp
cmake . -Bbuild
cmake --build build

run the driver executable from the base directory (so that the python interpreter will be able to resolve import mypythonlib)

% build/driver
starting driver...
(c++) x: 1 2 3 
(python) computing dfdx elementwise ... 
(c++) f'(x): 1.38177 0.0770037 -2.82886