flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.37k stars 446 forks source link

Flet APK build error for psycopg2-binary Cannot_compile_native_modules #2523

Closed ssaravanan384900712 closed 2 months ago

ssaravanan384900712 commented 9 months ago

I have created a flet app that need to run SQL Queries with psycopg (postgresql client module )


**$ cat requirements.txt**
flet
psycopg2-binary

when i do $ flet build apk

` VERBOSE: Building wheels for collected packages: psycopg2-binary VERBOSE: Building wheel for psycopg2-binary (pyproject.toml): started VERBOSE: Building wheel for psycopg2-binary (pyproject.toml): finished with status 'error' VERBOSE: Failed to build psycopg2-binary /tmp/hostpython3.11_TYVJJF/python/lib/python3.11/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") error: subprocess-exited-with-error

× Building wheel for psycopg2-binary (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [33 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-311 creating build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/_range.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/tz.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/extensions.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/pool.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/extras.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/errors.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/init.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/sql.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/errorcodes.py -> build/lib.linux-x86_64-cpython-311/psycopg2 copying lib/_json.py -> build/lib.linux-x86_64-cpython-311/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-x86_64-cpython-311 creating build/temp.linux-x86_64-cpython-311/psycopg Cannot_compile_native_modules -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fdebug-default-version=4 -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -I/tools/deps/libedit/include -fPIC "-DPSYCOPG_VERSION=2.9.9 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140010 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/tmp/hostpython3.11_TYVJJF/python/include/python3.11 -I. -I/usr/include/postgresql -I/usr/include/postgresql/14/server -I/usr/include/libxml2 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-311/psycopg/adapter_asis.o -Wdeclaration-after-statement

  It appears you are missing some prerequisite to build the package from source.

  You may install a binary package by installing 'psycopg2-binary' from PyPI.
  If you want to install psycopg2 from source, please install the packages
  required for the build and try again.

  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).

  error: command 'Cannot_compile_native_modules' failed: No such file or directory
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for psycopg2-binary ERROR: Could not build wheels for psycopg2-binary, which is required to install pyproject.toml-based projects

[notice] A new release of pip is available: 23.2.1 -> 23.3.2 [notice] To update, run: /tmp/hostpython3.11_TYVJJF/python/bin/python3 -m pip install --upgrade pip Deleting Flutter bootstrap directory /tmp/flet_flutter_build_JQUjPPFpcO Error building Flet app - see the log of failed command above. `

redis is working fine as it is a pure python module, but i need to connnct via psycopg

Please help

lekshmanmj commented 9 months ago

please follow this procedure. do p4a with psycopg https://flet.dev/docs/guides/python/packaging-app-for-distribution/#android Note: please remove psycopg from requirements.txt before next build.

ndonkoHenri commented 2 months ago

Closing this issue in favour of https://github.com/flet-dev/flet/issues/3839