Skip to content
nptmpl @ nguyenpanda.com v1.1.0

cpp/pybind-c

The industry-standard template for seamless C++/Python integration using PyBind11, Meson, and Ninja. Features expressive C++ bindings, automatic type conversions (STL, dicts, strings), and a high-performance build stack. Optimized for developer productivity with 'uv' environment orchestration.

Downloads today

0

Total downloads

1

Last updated

2026-05-26

v1.0.0 is latest

Versions

1

0 removed

Download v1.0.0

Clone with the CLI

nptmpl clone http://nptmpl.nguyenpanda.com/api/v1/templates/cpp/pybind-c

No @version resolves to the latest release (v1.0.0).

Maintainer nguyenpanda License MIT

Downloads over time

0 in the selected range

Files 11
README.md

Python C/C++ API Professional Template (PyBind11 + Meson)

A professional, high-performance template for creating Python extension modules using PyBind11, Meson, and Ninja. This is the most modern and recommended way to bind C++ to Python.

Features

  • PyBind11: The industry standard for seamless C++/Python integration.
  • Meson & Ninja: Lightning-fast build system and backend.
  • uv Support: High-speed environment management (auto-detects and falls back to standard Python).
  • C++20 Ready: Configured for modern C++ standards.
  • Automatic Type Conversion: Demonstrates seamless conversion between Python types (list, dict, string) and C++ types (std::vector, std::string, etc.).

Directory Structure

  • cppmodule/: The C++ extension source code.
    • src/: Implementation files (.cpp).
    • include/: Header files (.h).
  • lib/: Third-party C/C++ libraries (gitkept).
  • tests/: Python unit tests using pytest.
  • main.py: Entry point for quick demonstration and manual testing.
  • meson.build: The Meson build configuration.
  • Makefile: Convenient wrapper for environment and build management.

Getting Started

1. Initialize Environment

The Makefile automatically detects uv or standard Python, creates a virtual environment, and installs PyBind11, Meson, and Ninja.

make venv

2. Configure & Build

make setup
make build

3. Run Demonstration

make run

4. Run Tests

make tests

Makefile Targets

Target Description
venv Create virtual environment and install all dependencies (including PyBind11)
setup Initialize the Meson build directory (build_meson/)
build Compile the extension module using Ninja
run Run main.py
tests Run unit tests using pytest
clean Remove build artifacts
reset Deep clean: remove venv and all artifacts

Author

nguyenpanda
Email: [email protected]
Website: https://nguyenpanda.com

License

MIT License

Version history

Every release ever published, newest first.

v1.0.0 latest 1 downloads

Published 2026-05-26 08:52:47 by nguyenpanda

Related templates