Skip to content
 
 

Repository files navigation

python template cpp

A C++-Python project template

Build Status codecov License PyPI

Overview

C ABI

cpp/python-template-cpp builds libpython_template_cpp, a C ABI over the C++ code, declared in python_template_cpp/include/python_template_cpp/python_template_cpp.h. Wheels ship the library under python_template_cpp/lib and the header under python_template_cpp/include/python_template_cpp, and the pybind11 extension in cpp/python links against the library. The tests compile a C program against the installed package. Other projects build against the installed wheel with python_template_cpp.get_include(), get_library_dirs(), get_libraries(), and get_prefix().

HATCH_CPP_LIBRARY_SOURCE chooses where the library comes from at build time: bundled (the default, for wheels), external (a prebuilt library found through HATCH_CPP_LIBRARY_ROOT, pkg-config, or the conda prefix), or direct (compile the library sources into the extension).

cpp/CMakeLists.txt builds and installs the library without Python, with a CMake package config and a pkg-config file, for conda, vcpkg, and system packages:

cmake -S cpp -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build --prefix /path/to/prefix

Note

This library was generated using copier from the Base Python Project Template repository.