Try using Nanobind . Even though Python C API is what you aim for Nanobind has smaller binary files than pybind11. It is a reputed project and is deployed in many new libraries. Including mine. Will it work?