skillfed

PyBindGen

Python Bindings Generator

pybindgen v0.22.1 82.7K downloads/30d#14,146 on PyPI157
Copyleft license Abandoned released

What it is and what it does

PyBindGen is a code generator that reads C or C++ function and class definitions and produces Python extension code that wraps them. Instead of writing binding code by hand or using a template-heavy system like Boost.Python, you describe your API in Python and PyBindGen emits clean, self-contained C or C++ code that can be compiled into a Python module. The generated code has no external dependencies beyond Python headers.

The package supports a wide range of binding scenarios: simple functions, classes with virtual methods, reference-counted objects, templated classes, multiple inheritance, and in/out/inout parameters. It can optionally parse C++ headers using gccxml if available. However, it does not support converting Python exceptions to C++ or implementing callbacks, and the project has been inactive since early 2023.

Use it for:

  • Wrapping a legacy C library to make it accessible from Python without rewriting it
  • Exposing a C++ class hierarchy as a Python module while preserving virtual method dispatch
  • Generating bindings for a templated C++ class to use from Python code
  • Creating a Python interface to a performance-critical C function without manual binding code
  • Maintaining existing PyBindGen-generated modules in a stable codebase

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyBindGen generates clean C or C++ code that wraps C/C++ libraries as Python modules, without requiring Boost.Python or external runtime libraries.

Yes, if you need to generate or maintain Python bindings for C/C++ code and have no active development requirements. The package is stable and has no known vulnerabilities, but it is abandoned—no new features or bug fixes since 2022. Install it only for existing projects or when you are confident the generated code will not need updates. For new binding projects, consider actively maintained alternatives.

Install

pybindgen on PyPI

pip

pip install pybindgen

uv

uv add pybindgen

poetry

poetry add pybindgen

Installing PyBindGen

Before you install

Installation is straightforward with low friction (pure Python package, no runtime dependencies), but the project is abandoned—last release was 2022-03-30 and no commits since 2023-03-16. Use only if you need to maintain existing bindings or have specific compatibility requirements.

License in practice

Licensed under LGPLv2+, a copyleft license. Any Python module you generate with PyBindGen and distribute must comply with LGPLv2+ terms, including providing source code or a written offer for it.

Quickstart

pip install PyBindGen==0.22.1

from pybindgen import Module, param
m = Module('mymodule')
m.add_function('add', retval(int), [param('int', 'a'), param('int', 'b')])
m.generate(open('mymodule.cpp', 'w'))

A C/C++ compiler and Python development headers are required to compile the generated bindings; PyBindGen itself is pure Python but exists to generate code that must be compiled.

Verify before relying

  • Whether the generated code remains compatible with modern Python versions (3.9+) despite the project's abandonment
  • Current state of optional gccxml/pygccxml integration and whether it works with Python 3
  • Whether the generated bindings work reliably with recent C++ standards and compiler versions

Package facts

License not declared (copyleft)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,598 days since the last release
Last repo commit
First released
Downloads 82,662/month — #14,146 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: PyBindGen-0.22.1-py2.py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)Programming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software Development :: Build Tools

Tags

python c++ bindings generatorwrap c code pythonpython c bindingsgenerate python module from c++c library python wrapperpython binding code generationc++ to python bindings
binding-generationc-cpp-interop

More Build Tools packages