recipe: psycopg2 2.9.12 (+ flet-libpq 17.5)#84
Merged
Merged
Conversation
Adds the psycopg2 PostgreSQL driver (flet-dev/flet#3204) for iOS and Android, plus its native dependency flet-libpq. - flet-libpq 17.5: PostgreSQL's libpq, built from the release tarball (client library only). Ships the static libpq.a + libpgcommon/libpgport archives, headers and a relocatable pg_config shim, alongside a shared libpq.so. Cross-compile fixes: ac_cv_header_langinfo_h=no (Android API 24 hides nl_langinfo), strip quotes from CFLAGS/LDFLAGS (postgres bakes them into config_info.c string literals on iOS), and make all-lib + pre-touch libpq-refs-stamp (iOS _atexit false-positive). - psycopg2 2.9.12: a Cython C-extension that statically links libpq + OpenSSL into _psycopg.so. mobile.patch ships the *_shlib.a PIC archives, links OpenSSL + the extra archives unconditionally (psycopg2 only does so in finalize_darwin/finalize_linux, which the cross sys.platform matches neither), and reads pg_config from the PG_CONFIG env var. Tested: built green on Android arm64-v8a and iOS (device + arm64/x86_64 sim), Python 3.12. Live on-device round-trip (connect + SELECT against PostgreSQL 17.10) passes on an Android emulator and an iOS simulator.
A native lib that a C-extension STATICALLY links is folded into the extension's
own .so, so it is needed at build time but not at runtime. requirements.host,
however, promotes every flet-* dep to the wheel's Requires-Dist, so the consuming
app bundles the unused flet-lib* wheel (~2.7 MB android / ~3.9 MB iOS of dead
weight per app).
Add requirements.host_build: installed into the cross environment exactly like
host (its opt/include + opt/lib wired into CFLAGS/LDFLAGS and pkg-config), but
excluded from Requires-Dist (the promotion loop only walks "host"). psycopg2
adopts it for flet-libpq; pymssql -> flet-libfreetds is a natural follow-on.
Also rewrites the stale requirements.build / requirements.host schema
descriptions: they carried chaquopy-heritage claims (a "cmake" build keyword
generating chaquopy.toolchain.cmake; "openssl"/"sqlite"/"python" host keyword
special-cases; a $SRC_DIR/../requirements extraction path; a ">=" Requires-Dist
pin) that the current builders do not implement. They now accurately describe the
build vs cross environment, the install_root CFLAGS/LDFLAGS/pkg-config wiring, the
{platlib}/{prefix} script_env placeholders, and the flet-*-only "==" Requires-Dist
promotion.
Verified: psycopg2 builds green on android arm64 with host_build, the wheel no
longer lists flet-libpq in Requires-Dist, the app no longer bundles flet-libpq,
and psycopg2 still connects + SELECTs against live PostgreSQL 17.10 on-device.
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 the psycopg2 PostgreSQL driver for iOS and Android (closes flet-dev/flet#3204), its native dependency flet-libpq, and a small forge feature —
requirements.host_build— that psycopg2 uses to avoid bundling a library it static-links.Recipes
libpq.a+libpgcommon/libpgportarchives, headers, and a relocatablepg_configshim, alongside a sharedlibpq.so. Cross-compile fixes:ac_cv_header_langinfo_h=no(Android API 24 hidesnl_langinfo), strip quotes from CFLAGS/LDFLAGS (postgres bakes them intoconfig_info.cstring literals on iOS), andmake all-lib+ pre-touchlibpq-refs-stamp(iOS_atexitfalse-positive)._psycopg.so(Pattern E, like pymssql).mobile.patchships the*_shlib.aPIC archives, links OpenSSL + the extra archives unconditionally (psycopg2 only does so infinalize_darwin/finalize_linux, which the crosssys.platformmatches neither), and readspg_configfrom thePG_CONFIGenv var.Forge:
requirements.host_buildA native lib a C-extension static-links is folded into the extension's own
.so— needed at build time, but not at runtime.requirements.host, however, promotes everyflet-*dep to the wheel'sRequires-Dist, so the consuming app bundles the unused flet-lib wheel (~2.7 MB android / ~3.9 MB iOS of dead weight per app).requirements.host_buildinstalls the dep into the cross environment exactly likehost(itsopt/include/opt/libwired into CFLAGS/LDFLAGS and pkg-config), but excludes it fromRequires-Dist(the promotion loop only walkshost). psycopg2 uses it for flet-libpq; pymssql → flet-libfreetds is a natural follow-on adopter.This PR also rewrites the now-stale
requirements.build/hostschema descriptions, which carried chaquopy-heritage claims that the current builders don't implement (acmakebuild keyword generatingchaquopy.toolchain.cmake;openssl/sqlite/pythonhost keyword special-cases; a$SRC_DIR/../requirementsextraction path; a>=Requires-Dist pin). They now accurately describe the build-vs-cross environment, theinstall_rootCFLAGS/LDFLAGS/pkg-config wiring, the{platlib}/{prefix}script_envplaceholders, and theflet-*-only==Requires-Dist promotion.Tested
arm64-v8aand iOS (arm64device,arm64sim,x86_64sim),rrrrrrrr+ Python 3.12. (CI builds the full matrix.)SELECTround-trip agains PostgreSQL 17.10 succeeds on both platforms.host_buildverified: the psycopg2 wheel METADATA no longer lists flet-libpq inRequires-Dist; the built app no longer bundles the flet-libpq wheel; and psycopg2 still connects + queries on-device with it absent — confirming the dependency was purely build-time.