cwrap
cwrap - ctypes blanket
What it is and what it does
cwrap simplifies the process of wrapping C code for use in Python by building on top of ctypes. Rather than writing raw ctypes bindings by hand, cwrap provides a higher-level interface to reduce boilerplate and make C interop more ergonomic. It is intended for developers who need to call C functions or work with C data types from Python but want to avoid writing C extension modules.
The package has been in active development since its first release and is marked as Production/Stable. It carries no runtime dependencies, making it lightweight to add to a project. The GPL-3.0 copyleft license means you must ensure compatibility with your project's licensing model before use.
Use it for:
- Wrapping a C library to call its functions from Python without writing a C extension module
- Defining Python-friendly interfaces to C structs and data types for scientific or systems code
- Rapid prototyping of C bindings during development before committing to a full extension
- Integrating legacy C code into a Python application without rewriting it
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
cwrap is a Python wrapper around C code that builds on ctypes, allowing you to call C functions and work with C data structures from Python.
Yes, if you need to call C code from Python and prefer a higher-level wrapper over raw ctypes, and your project is compatible with GPL-3.0 copyleft licensing. The package is actively maintained, has no dependencies, and supports modern Python versions. If your project cannot use GPL-3.0 code, do not install.
Install
cwrap on PyPI
pip
pip install cwrapuv
uv add cwrappoetry
poetry add cwrapInstalling cwrap
Before you install
Low friction installation with no runtime dependencies. Active maintenance: last commit 2026-07-06, release 43 days old. Supports Python 3.11 through 3.14.
License in practice
GPL-3.0 copyleft license. You must distribute derivative works under the same license; use in proprietary software requires careful review or separate licensing.
Quickstart
pip install cwrap
import cwrap
# See examples/ directory in repository for usage patterns
Requires Python 3.11 or later
Verify before relying
- Whether cwrap generates wrapper code or provides a runtime abstraction layer
- What C library features are supported (structs, callbacks, pointers, etc.)
- Performance overhead compared to direct ctypes use
Package facts
| License | GPL-3.0 (copyleft) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 43 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 102,133/month — #12,888 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cwrap-1.6.16-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pyclibraryParses C header files and automates…
permissive · top 15,000 on PyPI
pywin32-ctypesA pure-Python reimplementation of pywin32 that…
permissive · top 5,000 on PyPI
jaraco.windowsProvides a pure-Python interface to Windows…
permissive · top 15,000 on PyPI
pyseccomppyseccomp provides a pure-Python interface to…
permissive · top 5,000 on PyPI
unrarProvides Python access to RAR archive files…
copyleft · top 15,000 on PyPI
ctypesgenctypesgen parses C header files and…
permissive · top 15,000 on PyPI
nanobindnanobind exposes C++ types in Python and vice…
permissive · top 5,000 on PyPI
pyprctlProvides a pure-Python interface to Linux's…
permissive · top 15,000 on PyPI
rpy2-rinterfacerpy2-rinterface provides a low-level…
copyleft · top 15,000 on PyPI
rpy2-robjectsProvides a Python interface to call R code and…
copyleft · top 15,000 on PyPI