Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lynnporu/annotatec
Python library which allows you to annotate C code and use it for ctypes.
https://github.com/lynnporu/annotatec
annotations ctypes ctypes-bindings python
Last synced: 9 days ago
JSON representation
Python library which allows you to annotate C code and use it for ctypes.
- Host: GitHub
- URL: https://github.com/lynnporu/annotatec
- Owner: lynnporu
- License: mit
- Created: 2021-12-25T12:30:09.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T18:21:39.000Z (almost 3 years ago)
- Last Synced: 2024-09-14T11:53:15.620Z (about 2 months ago)
- Topics: annotations, ctypes, ctypes-bindings, python
- Language: Python
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![PyPI](https://img.shields.io/pypi/v/annotatec.svg)](https://pypi.python.org/pypi/annotatec)
![GitHub repo size](https://img.shields.io/github/repo-size/lynnporu/annotatec)
![GitHub](https://img.shields.io/github/license/lynnporu/annotatec)------------
**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](https://docs.python.org/3/library/ctypes.html)-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.
## How to install
This library can be installed with `pip`:
```bash
pip install annotatec
```Or build it and install yourself:
```bash
pip install git+https://github.com/lynnporu/annotatec.git#egg=annotatec
```## 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:
```c
#include "lib.h"
int sum(int a, short b, long long c) { return a + b + c; }
````lib.h` source:
```c
/* @function sum
* @return int
* @argument int
* @argument short
* @argument longlong
*/
int sum(int, short, long long);
```Here's a Python wrapper:
```python
import annotateclibc = annotatec.Loader(
library="lib.so", headers=["lib.h"])
```That's all! Now you can test it like so:
```python
>>> libc.sum(1, 2, 3)
<<< 6
```
## ReferenceRead detailed reference in [wiki](https://github.com/lynnporu/annotatec/wiki)-pages.