Fix python bindings on macOS (#117)

* Fix python bindings on macOS

* Update workflow

* Remove unnecessary Makefile vars

* Add src dir to include dirs

* Fix phony
This commit is contained in:
Justin Traglia 2023-02-07 16:13:54 -06:00 committed by GitHub
parent e487800529
commit fd029a7d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 12 deletions

View File

@ -32,7 +32,7 @@ jobs:
- name: Build Python bindings
run: |
cd bindings/python
make ckzg.so
make install
- name: Test
run: |
cd bindings/python

View File

@ -1,17 +1,14 @@
INCLUDE_DIRS = .. ../../src ../../inc
INCLUDE_PY = $(shell python3 -c 'import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))')
FIELD_ELEMENTS_PER_BLOB?=4096
.PHONY: all
all: install test ecc_test
all: test ecc_test
.PHONY: install
install: setup.py ckzg.c
python3 setup.py install
test: tests.py ckzg.so
.PHONY: test
test: tests.py
python3 $<
ecc_test: py_ecc_tests.py ckzg.so
.PHONY: ecc_test
ecc_test: py_ecc_tests.py
python3 $<
ckzg.so: ckzg.c ../../src/c_kzg_4844.o ../../lib/libblst.a
clang -O -Wall -shared -fPIC -Wl,-Bsymbolic -I${INCLUDE_PY} ${addprefix -I,${INCLUDE_DIRS}} -DFIELD_ELEMENTS_PER_BLOB=${FIELD_ELEMENTS_PER_BLOB} -o $@ $^

18
bindings/python/setup.py Normal file
View File

@ -0,0 +1,18 @@
from distutils.core import setup, Extension
def main():
setup(
name="ckzg",
version="1.0.0",
description="Python interface for C-KZG-4844",
ext_modules=[
Extension(
"ckzg",
sources=["ckzg.c", "../../src/c_kzg_4844.c"],
include_dirs=["../../inc", "../../src"],
define_macros=[("FIELD_ELEMENTS_PER_BLOB", "4096")],
library_dirs=["../../lib"],
libraries=["blst"])])
if __name__ == "__main__":
main()