PyBindGen
Python Bindings Generator
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 pybindgenuv
uv add pybindgenpoetry
poetry add pybindgenInstalling 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
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
pybind11-globalA header-only C++ library that generates Python…
permissive · top 15,000 on PyPI
pybind11pybind11 is a header-only C++ library that…
permissive · top 1,000 on PyPI
pycupsProvides Python bindings to the CUPS printing…
copyleft · top 15,000 on PyPI
p4pythonp4python wraps the Perforce C++ API to provide…
unclear · top 15,000 on PyPI
pywin32-ctypesA pure-Python reimplementation of pywin32 that…
permissive · top 5,000 on PyPI
cxxheaderparserParses C++ header files into Python data…
permissive · top 15,000 on PyPI
pyclibraryParses C header files and automates…
permissive · top 15,000 on PyPI
shiboken2Shiboken2 provides Python access to metadata…
copyleft · top 15,000 on PyPI
cppyy-clingProvides Cling, an LLVM-based interactive C++…
copyleft · top 15,000 on PyPI
xpress9Xpress9 is a Python wrapper for Microsoft's…
permissive · top 15,000 on PyPI