Skip to main content

Create annotations for ctypes straight in your C code

Project description

PyPI GitHub repo size GitHub


annotatec helps you create Python packages with C embeddings.

Imagine you're developing C library and already have more than 50 functions. Sometimes you change signatures of old functions or rename them. It'll be headache to write and support all ctypes-declarations for Python wrapper. annotatec will create all Python objects for you. All you need is to provide declarations, which can be placed directly into your C code.

Minimal livable example

You have some library lib.c and it's header lib.h. These files were compiled into lib.so (or lib.dll in Windows).

lib.c source:

#include "lib.h"
int sum(int a, short b, long long c) { return a + b + c; }

lib.h source:

/* @function sum
 * @return int
 * @argument int
 * @argument short
 * @argument longlong
 */
int sum(int, short, long long);

Here's a Python wrapper:

import annotatec

libc = annotatec.Loader(
    library="lib.so", headers=["lib.h"])

That's all! Now you can test it like so:

>>> libc.sum(1, 2, 3)
<<< 6

Reference

Read detailed reference in wiki-pages.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

annotatec-1.0.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

annotatec-1.0-py3-none-any.whl (2.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page