fix(python): flatten packing buffers and package Cargo libraries
This commit is contained in:
parent
f081a808ea
commit
912a267028
1 changed files with 355 additions and 9 deletions
23
klamath_rs_ext/klamath_rs_ext.py
Normal file
23
klamath_rs_ext/klamath_rs_ext.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""CFFI ABI access to the Cargo-built shared library."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
from cffi import FFI
|
||||
|
||||
|
||||
ffi = FFI()
|
||||
header = Path(__file__).with_name("_ffi.h").read_text()
|
||||
ffi.cdef("\n".join(line for line in header.splitlines() if not line.lstrip().startswith("#")))
|
||||
|
||||
if sys.platform == "win32":
|
||||
filename = "klamath_rs_ext.dll"
|
||||
elif sys.platform == "darwin":
|
||||
filename = "libklamath_rs_ext.dylib"
|
||||
else:
|
||||
filename = "libklamath_rs_ext.so"
|
||||
|
||||
# An explicit override supports source-tree development without copying binaries
|
||||
# into the package. Installed wheels load only their bundled native library.
|
||||
library = Path(os.environ["KLAMATH_RS_LIBRARY"]) if "KLAMATH_RS_LIBRARY" in os.environ else Path(__file__).with_name(filename)
|
||||
lib = ffi.dlopen(str(library.resolve()))
|
||||
Loading…
Reference in a new issue