skillfed

cwrap

cwrap - ctypes blanket

cwrap v1.6.16 102.1K downloads/30d#12,888 on PyPI6
Copyleft license GPL-3.0 Active released

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 cwrap

uv

uv add cwrap

poetry

poetry add cwrap

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Other EnvironmentIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)Natural Language :: EnglishProgramming Language :: PythonProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: LibrariesTopic :: Utilities

Tags

ctypes wrappercall c code from pythonpython c bindingsc interop libraryc function wrapperpython ctypes abstractionc data structure binding
c-interopctypes

More Libraries packages