python bindings: build/install via integrated meson support

The meson build system has builtin support for python packaging, and
unlike hatchling it is spec-compliant. Additionally, meson is already
responsible for building the shared library itself, which the python
build backend can then distribute inside the wheel. This allows shipping
a wheel that can find its own liblc3.so via ctypes and doesn't require
passing paths to the library around, nor to install both separately and
hope that this works.
This commit is contained in:
Eli Schwartz
2024-02-16 15:42:30 -05:00
committed by Antoine SOULIER
parent a01c060807
commit 3f05fcb8f2
6 changed files with 27 additions and 5 deletions

View File

@@ -17,6 +17,8 @@
import array
import ctypes
import enum
import glob
import os
from ctypes import c_bool, c_byte, c_int, c_uint, c_size_t, c_void_p
from ctypes.util import find_library
@@ -55,7 +57,12 @@ class _Base:
raise ValueError("Invalid sample rate: %d Hz" % samplerate)
if libpath is None:
libpath = find_library("lc3")
mesonpy_lib = glob.glob(os.path.join(os.path.dirname(__file__), '.lc3.mesonpy.libs', '*lc3*'))
if mesonpy_lib:
libpath = mesonpy_lib[0]
else:
libpath = find_library("lc3")
if not libpath:
raise Exception("LC3 library not found")