prism-sys 0.1.3

Raw FFI bindings to the prism speech library
Documentation
[project]
name = "prismatoid"
dynamic = ["version"]
description = "The Platform-Agnostic Reader Interface for Speech and Messages"
readme = "README.md"
authors = [
    { name = "Ethin Probst", email = "ethindp@pm.me" }
]
requires-python = ">=3.10"
dependencies = [
    "cffi>=2.0.0",
]
license = "MPL-2.0"
license-files = [
    "LICENSE",
    "LICENSES/**/*",
    "NOTICE"
]

[tool.uv]
cache-keys = [{ file = "pyproject.toml" }, { file = "src/**/*.{h,c,hpp,cpp}" }, { file = "CMakeLists.txt" }]

[build-system]
requires = ["scikit-build-core>=0.10", "cffi>=2.0.0", "pcpp>=1.30"]
build-backend = "scikit_build_core.build"

[dependency-groups]
dev = [
    "moonshine-voice>=0.0.69",
    "numpy>=2.2.6",
    "packaging>=26.0",
    "piper-tts>=1.4.2",
    "pocket-tts>=2.1.0",
    "pytest>=9.0.2",
    "pytest-timeout>=2.4.0",
    "silero-vad>=6.2.1",
    "sounddevice>=0.5.5",
    "win32more>=0.8.0 ; sys_platform == 'win32'",
]

[tool.scikit-build]
minimum-version = "build-system.requires"
build-dir = "build/{wheel_tag}"
cmake.version = ">=3.31.0"
cmake.define = { PRISM_ENABLE_TESTS = "OFF", PRISM_ENABLE_GDEXTENSION = "OFF", PRISM_ENABLE_LEGACY_BACKENDS = "ON", PRISM_ENABLE_POWER_MANAGEMENT = "ON"}
cmake.source-dir = "."
build.verbose = true
wheel.packages = ["bindings/py/prism/prism"]
wheel.py-api = "cp310"
sdist.include = [
  "CMakeLists.txt",
  "cmake/**",
  "include/**",
  "source/**",
  "defs/**",
  "android/**",
  "bindings/py/**",
  "doc/**",
  "gradle/**",
  "tests/**",
  "build.gradle",
  "gradle.properties",
  "gradlew",
  "gradlew.bat",
  "pyproject.toml",
  ".python-version",
  "settings.gradle",
  "uv.lock",
  "LICENSE",
  "LICENSES",
  "NOTICE",
  "idl",
  "demos",
  "pytest.ini",
  "third_party",
  "shims",
  "winelibs",
  "tools",
]
sdist.exclude = [
  ".venv",
  ".git",
  ".vscode",
  ".idea",
  "build",
  "dist",
  "__pycache__",
  "*.egg-info",
]

[tool.cibuildwheel]
build = "cp310-* cp311-* cp312-* cp313-* cp314-* cp314t-*"
build-verbosity = 1
container-engine = { name = "podman", create-args = ["--pull=newer"] }
manylinux-x86_64-image = "manylinux_2_34"
manylinux-i686-image = "manylinux_2_34"
manylinux-pypy_x86_64-image = "manylinux_2_34"
manylinux-aarch64-image = "manylinux_2_34"
manylinux-ppc64le-image = "manylinux_2_34"
manylinux-s390x-image = "manylinux_2_34"
manylinux-riscv64-image = "manylinux_2_39"
manylinux-pypy_aarch64-image = "manylinux_2_34"
manylinux-pypy_i686-image = "manylinux_2_34"

[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"]
before-all = [
    """
    set -euo pipefail
    if command -v dnf >/dev/null 2>&1; then
        rhel_ver=$(rpm -E %rhel 2>/dev/null)
        if [[ "$rhel_ver" =~ ^[0-9]+$ ]]; then
            dnf install -y dnf-plugins-core
            dnf config-manager --set-enabled crb 2>/dev/null || dnf config-manager --set-enabled powertools 2>/dev/null || true
            dnf install -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${rhel_ver}.noarch.rpm"
        fi
        dnf install -y speech-dispatcher-devel ninja-build pkgconf-pkg-config git curl xz gstreamer1-devel gstreamer1-plugins-base-devel dbus-daemon libffi-devel pcre2-devel zlib-devel gettext gettext-devel
    elif command -v apk >/dev/null 2>&1; then
        apk add --no-cache speech-dispatcher-dev build-base ninja pkgconf git curl xz gstreamer-dev gst-plugins-base-dev dbus python3 libffi-dev pcre2-dev zlib-dev gettext-dev coreutils
    elif command -v apt-get >/dev/null 2>&1; then
        export DEBIAN_FRONTEND=noninteractive
        apt-get update
        apt-get install -y libspeechd-dev libdbus-1-dev wine64-tools build-essential ninja-build pkg-config git curl xz-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev dbus-daemon python3 libffi-dev libpcre2-dev zlib1g-dev gettext
    fi
    /opt/python/cp311-cp311/bin/pip install --quiet --upgrade 'meson>=1.3.2'
    export PATH=/opt/python/cp311-cp311/bin:$PATH
    GLIB_VERSION=2.88.1
    GLIB_SERIES="${GLIB_VERSION%.*}"
    curl -fL "https://download.gnome.org/sources/glib/${GLIB_SERIES}/glib-${GLIB_VERSION}.tar.xz" -o glib-${GLIB_VERSION}.tar.xz
    curl -fL "https://download.gnome.org/sources/glib/${GLIB_SERIES}/glib-${GLIB_VERSION}.sha256sum" -o glib.sha256sum
    sha256sum --ignore-missing -c glib.sha256sum
    tar xJf glib-${GLIB_VERSION}.tar.xz
    cd "glib-${GLIB_VERSION}"
    meson setup build --prefix=/opt/prism --buildtype=release -Dtests=false -Dintrospection=disabled -Ddocumentation=false -Dman-pages=disabled
    meson compile -C build
    meson install -C build
    cd ..
    rm -rf "glib-${GLIB_VERSION}"
    export PKG_CONFIG_PATH=/opt/prism/lib64/pkgconfig:/opt/prism/lib/pkgconfig:${PKG_CONFIG_PATH:-}
    SIGCPP_VERSION=3.6.0
SIGCPP_SERIES="${SIGCPP_VERSION%.*}"
curl -fL "https://download.gnome.org/sources/libsigc++/${SIGCPP_SERIES}/libsigc++-${SIGCPP_VERSION}.tar.xz" -o libsigc++-${SIGCPP_VERSION}.tar.xz
curl -fL "https://download.gnome.org/sources/libsigc++/${SIGCPP_SERIES}/libsigc++-${SIGCPP_VERSION}.sha256sum" -o sigcpp.sha256sum
sha256sum --ignore-missing -c sigcpp.sha256sum
tar xJf libsigc++-${SIGCPP_VERSION}.tar.xz
cd "libsigc++-${SIGCPP_VERSION}"
meson setup build --prefix=/opt/prism --buildtype=release -Dbuild-documentation=false -Dbuild-examples=false -Dbuild-tests=false
meson compile -C build
meson install -C build
cd ..
rm -rf "libsigc++-${SIGCPP_VERSION}"
GLIBMM_VERSION=2.88.0
GLIBMM_SERIES="${GLIBMM_VERSION%.*}"
curl -fL "https://download.gnome.org/sources/glibmm/${GLIBMM_SERIES}/glibmm-${GLIBMM_VERSION}.tar.xz" -o glibmm-${GLIBMM_VERSION}.tar.xz
curl -fL "https://download.gnome.org/sources/glibmm/${GLIBMM_SERIES}/glibmm-${GLIBMM_VERSION}.sha256sum" -o glibmm.sha256sum
sha256sum --ignore-missing -c glibmm.sha256sum
tar xJf glibmm-${GLIBMM_VERSION}.tar.xz
cd "glibmm-${GLIBMM_VERSION}"
meson setup build --prefix=/opt/prism --buildtype=release -Dbuild-documentation=false -Dbuild-examples=false -Dmaintainer-mode=false
meson compile -C build
meson install -C build
cd ..
rm -rf "glibmm-${GLIBMM_VERSION}"
    """,
]
environment = { CMAKE_BUILD_PARALLEL_LEVEL = "4", PKG_CONFIG_PATH = "/opt/prism/lib64/pkgconfig:/opt/prism/lib/pkgconfig", LD_LIBRARY_PATH = "/opt/prism/lib64:/opt/prism/lib" }
repair-wheel-command = [
    """
    POLICY=$(find /opt/_internal -name manylinux-policy.json 2>/dev/null | head -1)
    if [ -z "$POLICY" ]; then
        POLICY=$(find / -name manylinux-policy.json 2>/dev/null | head -1)
    fi
    echo "Patching policy at: $POLICY"
    python3 -c "
import json, sys
p = sys.argv[1]
data = json.load(open(p))
strip = ('libglib-2.0', 'libgobject-2.0', 'libgthread-2.0', 'libgmodule-2.0', 'libgio-2.0')
for entry in data:
    if 'lib_whitelist' in entry:
        entry['lib_whitelist'] = [x for x in entry['lib_whitelist'] if not x.startswith(strip)]
json.dump(data, open(p, 'w'))
" "$POLICY"
    auditwheel repair -w {dest_dir} {wheel}
    """
]

[tool.cibuildwheel.macos]
archs = ["arm64", "x86_64"]
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0", CMAKE_OSX_DEPLOYMENT_TARGET = "11.0", CMAKE_BUILD_PARALLEL_LEVEL = "4"}
before-build = ["xcode-select --print-path || xcode-select --install"]

[tool.cibuildwheel.windows]
archs = ["AMD64", "ARM64"]
environment = { CMAKE_BUILD_PARALLEL_LEVEL = "4" }
repair-wheel-command = "delvewheel repair --exclude prism.dll -w {dest_dir} -v {wheel}"

[[tool.cibuildwheel.overrides]]
select = "*-win_arm64"
environment = { CMAKE_SYSTEM_PROCESSOR = "ARM64", CMAKE_BUILD_PARALLEL_LEVEL = "4"}

   [tool.scikit-build.metadata.version]
   provider = "scikit_build_core.metadata.regex"
   input = "CMakeLists.txt"
   regex = '''project\(\s*prism\s+VERSION\s+(?P<value>[0-9.]+)'''

[tool.ruff]
extend-exclude = [
    "third_party",
    "gdextension/godot-cpp",
]

[tool.ruff.lint]
extend-select = ["ERA", "YTT", "ANN", "ASYNC", "S", "BLE", "B", "A", "COM", "C4", "DTZ", "T10", "EXE", "FIX", "FA", "ISC", "ICN", "LOG", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "SLF", "SIM", "SLOT", "TID", "TD", "TC", "ARG", "PTH", "FLY", "I", "C90", "NPY", "PD", "N", "PERF", "W", "F", "PGH", "PL", "UP", "FURB", "RUF"]
ignore = ["COM812", "PLW0603"]

[tool.ruff.lint.pylint]
max-args = 8

[tool.ruff.lint.per-file-ignores]
"demos/**" = ["T201"]

[tool.cibuildwheel.android]
environment = { SKBUILD_WHEEL_PY_API = "", CMAKE_BUILD_PARALLEL_LEVEL = "4" }
repair-wheel-command = "auditwheel repair --ldpaths {ldpaths} --exclude libprism.so -w {dest_dir} {wheel}"

[[tool.scikit-build.overrides]]
if.platform-system = "android"
wheel.py-api = ""