Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/skills/local-recipe-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ for i in $(seq 1 30); do grep EXIT "$DATA/Library/Caches/console.log" 2>/dev/nul
- **Big models (MBs): drop next to the test locally; the test discovers it by presence and skips otherwise.** Precedent sherpa-onnx `silero_vad.onnx` (2.2 MB): `if not os.path.exists(model): pytest.skip("silero_vad.onnx not bundled")`. CI (no asset) skips; your local loop runs REAL inference. `.gitignore` has `recipes/*/tests/*.onnx` so the asset can never be committed (that would silently flip the CI skip into a real run and embed MBs in git history) — extend the pattern for other formats.
- **Tiny models (~KB): COMMIT them so CI runs real inference too.** Precedent tflite-runtime's 1 KB `dense_relu.tflite` (generated with desktop TF at a fixed seed, expected outputs asserted).

Test-only deps — packages the tests import that are NOT in the recipe's Requires-Dist (e.g. numpy) — go in the recipe's meta.yaml `test.requires` (a list of PEP 508 specs; this replaced the former `recipes/<pkg>/tests/requirements.txt`, and `stage_recipe.sh` now errors on a stale one). `stage_recipe.sh` injects them into the generated tester `pyproject.toml` `dependencies` (read via `read_meta_list.py`). Each must resolve for the MOBILE target: pure-Python from PyPI, or a recipe on pypi.flet.dev / seeded into `dist/`.
Test-only deps — packages the tests import that are NOT in the recipe's Requires-Dist (e.g. numpy) — go in the recipe's meta.yaml `test.requires` (a list of PEP 508 specs).

Path-hungry packages (read bundled DATA via `__file__`) also need a top-level meta.yaml `extract_packages:` list on Android — see `forge-error-catalogue` § the `sitepackages.zip` class.

Expand Down
3 changes: 2 additions & 1 deletion .claude/skills/new-mobile-recipe/templates/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
- Keep tests deterministic and network-free (fixed seeds; no downloads; asset
files only if tiny and shipped in the recipe's tests/ dir)
- Test-only deps (e.g. numpy for a package that doesn't require it) go in
tests/requirements.txt — one PEP 508 spec per line
meta.yaml under `test.requires` (a list of PEP 508 specs) — NOT a
tests/requirements.txt file (that is no longer read)

Replace <package> with the import name (NOT the PyPI name — these can differ).
"""
Expand Down
87 changes: 87 additions & 0 deletions recipes/tflite-runtime/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{% set version = "2.21.0" %}

package:
name: tflite-runtime
version: '{{ version }}'

build:
number: 1
script_env:
_PYTHON_SYSCONFIGDATA_NAME: '{sysconfigdata_name}'
# Consumed by the patch-added PEP 517 shim (_forge/forge_tflite_backend.py):
# standalone host-flatc build + cross cmake of tensorflow/lite building
# ONLY the _pywrap_tensorflow_interpreter_wrapper pybind module, then
# upstream's exact 5-file python package staging. The wrapper target has
# no FindPython -- Python/numpy/pybind11 headers are plain -I injections
# (upstream's own mechanism); numpy+pybind11 resolve from the cross venv
# via {platlib}, no imports needed (target numpy is not host-runnable).
FORGE_WRAPPER_INCLUDES: >-
-I{HOST_PYTHON_HOME}/include/python{py_version_short}
-I{platlib}/numpy/_core/include
-I{platlib}/pybind11/include
# {% if sdk == 'android' %}
# Multi-token -D values can't ride inside FORGE_CMAKE_ARGS (the shim
# shlex-splits it), so linker flags get their own var. libpython is
# linked explicitly like every other forge pybind wheel: upstream
# relies on manylinux-style lazy resolution, Android wants DT_NEEDED.
FORGE_SHARED_LINKER_FLAGS: >-
-Wl,-z,max-page-size=16384
-L{HOST_PYTHON_HOME}/lib -lpython{py_version_short}
# XNNPACK stays at its default (ON) except armeabi-v7a, where the shim
# follows upstream's own pip script convention (OFF for all 32-bit arm).
FORGE_CMAKE_ARGS: >-
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DCMAKE_TOOLCHAIN_FILE={NDK_ROOT}/build/cmake/android.toolchain.cmake
-DANDROID_ABI={ANDROID_ABI}
-DANDROID_NATIVE_API_LEVEL={ANDROID_API_LEVEL}
-DANDROID_STL=c++_shared
# {% else %}
# iOS: the wrapper target links no libpython (no FindPython anywhere),
# and apple's two-level namespace would fail the link on the undefined
# python symbols -- resolve them at dlopen instead.
FORGE_SHARED_LINKER_FLAGS: -Wl,-undefined,dynamic_lookup
FORGE_CMAKE_ARGS: >-
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DCMAKE_SYSTEM_NAME=iOS
-DCMAKE_OSX_SYSROOT={{ sdk }}
-DCMAKE_OSX_DEPLOYMENT_TARGET={{ sdk_version }}
-DCMAKE_OSX_ARCHITECTURES={{ arch }}
-DFLATBUFFERS_BUILD_FLATC=OFF
-DFLATBUFFERS_INSTALL=OFF
# {% endif %}

source:
# tflite-runtime has no sdist (upstream wheels come from
# tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh);
# build from the TF release tree. The lite/ CMake superbuild fetches its
# pinned deps (abseil/eigen/xnnpack/ruy/flatbuffers/...) at configure.
url: https://github.com/tensorflow/tensorflow/archive/refs/tags/v{{ version }}.tar.gz

requirements:
build:
- setuptools
- wheel
- cmake
host:
# Build-time headers only (via FORGE_WRAPPER_INCLUDES {platlib} paths).
# numpy>=2 headers yield binaries compatible with numpy 1.x AND 2.x;
# numpy is also the wheel's one runtime dep (install_requires in the
# shim's setup.py, matching upstream setup_with_binary.py).
- numpy ^2.0.0
- pybind11
# {% if sdk == 'android' %}
# C++20 -> libc++_shared.so at runtime (iOS links the system libc++).
- flet-libcpp-shared >=27.2.12479018
# {% endif %}

patches:
- mobile.patch

test:
# The tests run real inference and import numpy, which the wheel itself
# requires — but the recipe-tester installs only flet + pytest + the recipe,
# so declare it here. (Replaces the former tests/requirements.txt.)
requires:
- numpy
Loading
Loading