mirror of
https://github.com/google/liblc3.git
synced 2026-04-17 21:25:30 +00:00
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:
committed by
Antoine SOULIER
parent
a01c060807
commit
3f05fcb8f2
@@ -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")
|
||||
|
||||
|
||||
3
python/meson.build
Normal file
3
python/meson.build
Normal file
@@ -0,0 +1,3 @@
|
||||
py = import('python').find_installation()
|
||||
|
||||
py.install_sources('lc3.py')
|
||||
@@ -1,16 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "lc3"
|
||||
version = "0.0.1"
|
||||
license = "Apache-2.0"
|
||||
authors = [
|
||||
{ name="Antoine Soulier", email="asoulier@google.com" },
|
||||
]
|
||||
description = "LC3 Codec library wrapper"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/google/liblc3"
|
||||
Reference in New Issue
Block a user