skillfed

pyclibrary

C binding automation

pyclibrary v0.3.0 399.7K downloads/30d#6,945 on PyPI72
Permissive license The MIT License (MIT) Copyright (c) 2010 Luke Campagnola Copyright (c) 2015 Matthieu Dartiailh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and… (full text in the JSON record) Active released

What it is and what it does

PyClibrary is a pure-Python C parser and ctypes binding automation library that reads C header files and extracts their definitions—macros, typedefs, structs, unions, enums, function prototypes, and global variables—then uses those definitions to simplify calling C libraries from Python. It evaluates typedefs down to their fundamental C types and can automatically build C structs and perform type conversions when invoking functions through ctypes' cdll or windll interfaces.

The package aims to be FFI-agnostic, presenting a backend-independent API; currently only ctypes is implemented, though a cffi backend is noted as theoretically possible. It depends only on pyparsing and runs on Python 3.10 and later. The library is a maintained fork of an earlier Launchpad project and is actively developed, making it suitable for projects that need to reduce boilerplate when wrapping existing C libraries.

Use it for:

  • Automatically generate Python ctypes wrappers from C header files to call compiled C libraries without manual struct and type definitions.
  • Parse and evaluate C macros and typedefs to determine their underlying C types for use in Python binding code.
  • Simplify integration of legacy C libraries into Python projects by automating the extraction of function signatures and struct layouts.
  • Build Python-friendly wrappers around Windows DLLs or Unix shared libraries with automatic type conversion on function calls.
  • Reduce maintenance burden when C library headers change by regenerating bindings from the updated headers.

Worth the install?

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

Parses C header files and automates ctypes-based bindings to C libraries, handling macros, typedefs, structs, unions, enums, and function prototypes with automatic type conversion.

Yes. Low install friction, active maintenance, no known vulnerabilities, and permissive MIT license make this a safe choice. Install it if you need to call C libraries from Python and want to avoid hand-writing ctypes boilerplate; skip it if you prefer explicit control over bindings or are already using a dedicated FFI tool like cffi.

Install

pyclibrary on PyPI

pip

pip install pyclibrary

uv

uv add pyclibrary

poetry

poetry add pyclibrary

Installing pyclibrary

Before you install

Low friction: pure-Python wheel with a single runtime dependency (pyparsing). Actively maintained as of 2026-07-17 with recent release history since 2015.

License in practice

MIT license (permissive): you may use, modify, and distribute this package freely in commercial and private projects, with minimal restrictions beyond preserving the license notice.

Quickstart

pip install pyclibrary

from pyclibrary import CParser
parser = CParser(['myheader.h'])
print(parser.defs['functions'])

Requires Python 3.10 or later; C header files must be present and syntactically valid for the parser to process them.

Verify before relying

  • Extent of C syntax coverage beyond the documented macro, typedef, struct, union, enum, function prototype, and global variable support.
  • Whether the ctypes backend handles all common calling conventions and platform-specific type mappings automatically.
  • Real-world performance on large or complex header files with heavy macro nesting or conditional compilation.

Package facts

License The MIT License (MIT) Copyright (c) 2010 Luke Campagnola Copyright (c) 2015 Matthieu Dartiailh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pyparsing
Maintenance actively maintained — 345 days since the last release
Last repo commit
First released
Downloads 399,719/month — #6,945 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pyclibrary-0.3.0-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Libraries :: Python Modules

Tags

c header parser pythonctypes bindings automationc library wrapper generatorparse c headersc struct type conversioncdll windll binding helperc function prototype parser
c-interopctypesheader-parsing

More Python Modules packages