Initial attempt to swig for python

This commit is contained in:
Ramana Kumar 2022-09-18 12:55:34 +01:00
parent 67c6a61a18
commit 8eb99bcc96
No known key found for this signature in database
GPG Key ID: ED471C788B900433
3 changed files with 21 additions and 0 deletions

4
.gitignore vendored
View File

@ -15,3 +15,7 @@ inc/blst_aux.h*
.vscode/
*.json
.clang-format
bindings/*/_*.so
bindings/python/*.py
bindings/python/*_wrap.c
__pycache__

9
bindings/c_kzg.swg Normal file
View File

@ -0,0 +1,9 @@
%module ckzg
%include "stdint.i"
%{
#include <stdbool.h>
#include "c_kzg.h"
%}
%rename(alloc_poly) new_poly;
%rename(alloc_poly_l) new_poly_l;
%include "../src/c_kzg.h"

8
bindings/python/Makefile Normal file
View File

@ -0,0 +1,8 @@
INCLUDE_DIRS = .. ../../src ../../inc
INCLUDE_PY = $(shell python -c 'import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))')
_ckzg.so: c_kzg_wrap.c ../../src/libckzg.a ../../lib/libblst.a
clang -O -Wall -shared -fPIC -Wl,-Bsymbolic -I${INCLUDE_PY} ${addprefix -I,${INCLUDE_DIRS}} -o $@ $^
c_kzg_wrap.c ckzg.py: ../c_kzg.swg
swig -O -python -outcurrentdir $<