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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file annotatec-1.0.tar.gz.

File metadata

  • Download URL: annotatec-1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.10

File hashes

Hashes for annotatec-1.0.tar.gz
Algorithm Hash digest
SHA256 c8a9f30ff3f24f21f3b91c4c8b8d04aab1ebd26ba1c34d8454a976263015c5ef
MD5 181261831e0fcbf5715d747f14d4d7e8
BLAKE2b-256 a256eed223df9c63850fe401ef3479daee3567537b193e2a1c573f817f4b6fa8

See more details on using hashes here.

File details

Details for the file annotatec-1.0-py3-none-any.whl.

File metadata

  • Download URL: annotatec-1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.10

File hashes

Hashes for annotatec-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9039b6a45aa8b0a5f996678f0d149430f7ee50473daa03a01e001b2db01dc22a
MD5 75230f4db4222d6687b748b17d08ab71
BLAKE2b-256 79edc3e992fbb8769d6f1d9673e6344e729a9d2b55e1d1d224fa1d0d2dc5d118

See more details on using hashes here.

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