diff --git a/.gitignore b/.gitignore index 5d60f4f..156761f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,7 @@ inc/blst_aux.h* .vscode/ *.json .clang-format +bindings/*/_*.so +bindings/python/*.py +bindings/python/*_wrap.c +__pycache__ diff --git a/bindings/c_kzg.swg b/bindings/c_kzg.swg new file mode 100644 index 0000000..c551fcd --- /dev/null +++ b/bindings/c_kzg.swg @@ -0,0 +1,9 @@ +%module ckzg +%include "stdint.i" +%{ +#include +#include "c_kzg.h" +%} +%rename(alloc_poly) new_poly; +%rename(alloc_poly_l) new_poly_l; +%include "../src/c_kzg.h" diff --git a/bindings/python/Makefile b/bindings/python/Makefile new file mode 100644 index 0000000..ab93c29 --- /dev/null +++ b/bindings/python/Makefile @@ -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 $<