recipe: pyzbar 0.1.9 (+ flet-libzbar, flet-libiconv)#82
Merged
Conversation
Native libzbar for the upcoming pyzbar recipe. Pattern H (ctypes-loaded shared lib): ships opt/lib/libzbar.so so serious-python surfaces it into Android jniLibs and an iOS embedded framework, for pyzbar to dlopen at runtime. - source: mchehab/zbar GitHub archive (no release tarball is published) — only configure.ac is shipped, so build.sh runs autoreconf to generate ./configure. - core decoder only (--without x/gtk/qt/imagemagick/jpeg/python/java/dbus, --disable-video/doc); Android shared + .so collapse, iOS static -> hand-linked shared (Darwin host triplet since config.sub lacks apple-ios). First attempt; iterating locally + on CI.
zbar's QR decoder (qrcode/qrdectxt.c) #includes <iconv.h> and calls iconv_open/iconv unconditionally (no HAVE_ICONV guard). Android bionic has no iconv at API 24, so libzbar fails to compile there. Add a static, PIC GNU libiconv 1.17 (flet-libiconv, platforms: [android]) and declare it as a host requirement of flet-libzbar (Android-gated). forge auto-injects the host-dep include/lib, so zbar AM_ICONV finds it and folds libiconv.a into libzbar.so. Verified locally (android arm64-v8a): flet-libiconv + flet-libzbar build; the resulting libzbar.so is self-contained (NEEDED = libm/libdl/libc only, no external libiconv.so, no libc++_shared). iOS uses the system libiconv.
pyzbar (QR/barcode reader) is a pure-Python ctypes wrapper around libzbar.
forge: PythonPackageBuilder.download_source_url now honors an explicit
source.url (GitHub tag archive) when present, else resolves the PyPI sdist as
before. Enables wheels-only / no-sdist Python packages (pyzbar publishes no
sdist). SimplePackageBuilder already did this; this brings the Python builder in
line. Additive — packages without source.url are unaffected.
pyzbar recipe:
- source.url = NaturalHistoryMuseum/pyzbar GitHub tag archive (no PyPI sdist).
- patches/mobile.patch: ctypes.util.find_library("zbar") returns None on
iOS/Android; patch the loader to dlopen the bundled libzbar from the
flet-libzbar wheel (opt/lib/libzbar.fwork on iOS, libzbar.so on Android).
- requirements.host flet-libzbar (both platforms) -> Requires-Dist via fix_wheel.
- tests: load libzbar + scan a blank Y800 buffer (no camera/files/network).
Verified locally: full chain builds on android arm64-v8a (flet-libiconv ->
flet-libzbar -> pyzbar). NOTE for CI: the inter-recipe host deps need
prebuild_recipes (or publishing flet-libiconv/flet-libzbar first); a plain push
fails to resolve flet-libiconv across isolated matrix jobs.
… platforms flet-libzbar autoreconfs the zbar git archive (only configure.ac shipped), whose configure.ac uses AM_GNU_GETTEXT -> autopoint. Install autoconf/automake/libtool + gettext/autopoint in the build step (apt on Android, brew + gettext-on-PATH on the macOS/iOS runner; gettext is keg-only). Also: the prebuild_recipes loop now respects each recipe's declared platforms (same gating the matrix applies), so an android-only lib (flet-libiconv) is not forced to build on iOS (where it failed at config.sub arm64-apple-ios-simulator).
Recipes now declare their own host build-tool setup in build.before_all instead of the CI workflow hardcoding apt/brew installs per recipe, so the workflow stays recipe-agnostic and recipes remain self-contained as more are added. - schema: new build.before_all (string or array; Jinja-rendered, can branch on sdk). - read_meta.py: generalized into one field reader -- keeps the matrix summary line (back-compat) and adds a "<dotted.field> [android|ios]" mode used to read build.before_all per platform (instead of a separate script). - build-wheels-version.yml: revert the recipe-specific apt/brew block to baseline (sqlite3, pkg-config); add a generic "Run recipe before_all" step that runs each built recipe's before_all. It loops PREBUILD_RECIPES + FORGE_PACKAGES because the recipe needing it (flet-libzbar) is a prebuild dep, not the matrix package. - forge: surface a recipe's before_all locally as a hint (forge never runs it). - flet-libzbar: declares its autotools+gettext setup (apt on Android; brew plus "brew link --force gettext" for keg-only autopoint on iOS).
Resolve .ci/read_meta.py: keep the generalized field reader (summary line + dotted-field mode for build.before_all), adopt mains build.number default of 1. meta-schema.yaml and build-wheels-version.yml auto-merged cleanly - mains zizmor hardening (SHA pins, permissions, persist-credentials, Summarize step, push-to-main test skip) and the before_all mechanism coexist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds pyzbar 0.1.9 for iOS and Android as a 3-recipe chain, plus two reusable forge/CI capabilities the chain needed:
source.urlfor Python packages —PythonPackageBuildernow honors an explicitsource.url, so wheels-only / no-sdist packages (like pyzbar) can be built.build.before_all— recipes declare their own host build-tool setup instead of the CI workflow hardcoding per-recipeapt/brewinstalls.Requested by flet-dev/flet#3563.
Recipes
platforms: [android]). zbar's QR decoder#includes<iconv.h>unconditionally and Android bionic has no iconv at API 24; iOS/macOS use the system libiconv.dlopens it at runtime). Built from the mchehab/zbar git archive (no release tarball), sobuild.shrunsautoreconf. Android links the static flet-libiconv; iOS uses the system libiconv.ctypeswrapper. No PyPI sdist → built from the GitHub tag archive viasource.url.patches/mobile.patchfixes the loader:ctypes.util.find_library('zbar')returnsNoneon iOS/Android, so it loads the bundled libzbar (opt/lib/libzbar.fworkon iOS,libzbar.soon Android).Forge / CI changes
src/forge/build.py—PythonPackageBuilder.download_source_urlhonorssource.urlwhen present (else resolves the PyPI sdist as before); + a local hint surfacing a recipe'sbefore_all. Additive — recipes withoutsource.url/before_allare unaffected.src/forge/schema/meta-schema.yaml— newbuild.before_all(string or array; Jinja-rendered)..ci/read_meta.py— generalized into one field reader: the existing matrix summary line plus a<dotted.field> [android|ios]mode (used to readbuild.before_all)..github/workflows/build-wheels-version.yml— a generic "run recipebefore_all" step (runs each built recipe's declared host setup — prebuild deps + the package), and theprebuild_recipesloop now honors declaredplatforms. The workflow no longer hardcodes recipe-specific installs.flet-libzbar's
before_allis the first user:autoconf/automake/libtool/gettext/autopointon Android (apt), and on iOSbrew install …+ a conditionalbrew link gettextfor the keg-onlyautopoint.Validation
before_allmechanism was validated end-to-end (flet-libzbar builds via the recipe-declared host setup; no autotools left hardcoded in CI).