--- id: ctypesgen version: "1.1.1" license: BSD-2-Clause license_treatment: permissive maintenance: aging --- # ctypesgen — Python wrapper generator for ctypes License: permissive · Maintenance: aging · Downloads: 168.6K/mo ## What it is and what it does ctypesgen is a command-line tool that reads C header files and generates Python code using ctypes to call functions in compiled C libraries. It handles preprocessor macros by translating them into equivalent Python functions, and can output either Python wrapper modules or JSON for use with other binding generators like Mork. The tool is designed for developers who need to integrate C libraries into Python projects without writing manual ctypes bindings. It supports platform-specific library loading, handles calling conventions, and can manage dependencies between libraries. The generated wrappers use ctypes directly, so they work on any platform with Python 3.7+ and the target C library available. Use it for: - Generate Python bindings for system libraries like APR or Neon to call their C functions directly. - Automate wrapper creation for third-party C libraries to avoid hand-writing ctypes boilerplate. - Create JSON output for generating Lua bindings via Mork using the alien module. - Handle platform-specific library loading and calling conventions automatically. - Translate C preprocessor macros into callable Python functions for library constants and utilities. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. ctypesgen parses C header files and automatically generates Python ctypes wrapper code, enabling direct calls to C library functions from Python without manual binding work. Yes, if you need to call C library functions from Python and want to avoid manual ctypes binding work. The low install friction and permissive license make it a practical choice. However, the aging maintenance status (last release October 2022) means you should verify that generated wrappers work correctly for your specific headers and libraries before committing to production use. ## Install pip install ctypesgen uv add ctypesgen poetry add ctypesgen ## Installing ctypesgen Before you install: Low install friction; pure Python wheel with no runtime dependencies. Maintenance is aging—last release October 2022, though the repository remains active with recent commits and no archived status. License in practice: BSD-2-Clause (permissive) allows commercial and private use with minimal restrictions; redistribution requires retaining copyright notice and disclaimer. Quickstart: pip install ctypesgen ctypesgen -lneon /usr/local/include/neon/ne_*.h -o neon.py Requires Python 3.7 or later; C header files and target library must be accessible on the system. Verify before relying: - Whether generated wrappers handle all C constructs equally well or have known limitations with complex types. - Current state of JSON output feature and compatibility with Mork for Lua binding generation. - How preprocessor macro function translation handles edge cases in real-world headers. ## Package facts - License: BSD-2-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 168.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ctypes wrapper generator, C header to Python bindings, automatic FFI binding generation, C library Python wrapper, ctypes code generation, parse C headers Python, foreign function interface generator, ctypes, code-generation, ffi [View on SkillFed](https://skillfed.io/packages/ctypesgen) · [View on PyPI](https://pypi.org/project/ctypesgen/)