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.16k stars 429 forks source link

Can't generate apk when add numpy #2725

Closed ahmedashraf344 closed 1 month ago

ahmedashraf344 commented 7 months ago

this is my requirment.txt

flet numpy

i have use p4a create to add numpy

i follow all steps the results is

(ahmed) ahmedashraf@ahmeds-mbp demoapp % flet build apk Creating Flutter bootstrap project...OK Customizing app icons and splash images...OK Generating app icons...OK Generating splash screens...OK Packaging Python app...Running package command Creating asset directory: /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/flet_flutter_build_IRvSqSxNkD/app Copying Python app from /Users/ahmedashraf/Desktop/demoapp to /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/serious_python_tempML3GJD Configured mobile platform with sitecustomize.py at /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/serious_python_sitecustomizeBp2W9V/sitecustomize.py Installing dependencies with pip command to /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/serious_python_tempML3GJD/pypackages Extracting Python distributive from /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/cpython-3.11.6+20231002-aarch64-apple-darwin-install_only.tar.gz to /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_qa99V4

/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_qa99V4/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

× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [14 lines of output]

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

A new release of pip is available: 23.2.1 -> 24.0 To update, run: /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_qa99V4/python/bin/python3 -m pip install --upgrade pip

Error building Flet app - see the log of failed command above. (ahmed) ahmedashraf@ahmeds-mbp demoapp %

Ambassador-of-programming commented 7 months ago

Hello. Unfortunately, at the moment it is impossible to use libraries that use code that is not pure Python, for example C++ and so on, when creating a mobile build from requirements.txt. Only pure python should be used. This problem should be solved in new updates.

Now it can be done using only special manupulations

ahmedashraf344 commented 7 months ago

is the new update coming soon ? @Ambassador-of-programming

MoreiraCristiano commented 7 months ago

I have the same problem but to SQLAlchemy ORM :/

prodat1 commented 6 months ago

I have the same problem when I use numpy in my requirements.txt. It only affects apk-builds. windows-builds have no trouble building

VERBOSE: Using cached numpy-1.26.4.tar.gz (15.8 MB)
VERBOSE: Installing build dependencies: started
VERBOSE: Installing build dependencies: finished with status 'done'
VERBOSE: Getting requirements to build wheel: started
VERBOSE: Getting requirements to build wheel: finished with status 'done'
VERBOSE: Installing backend dependencies: started
VERBOSE: Installing backend dependencies: finished with status 'error'
aniqu18 commented 6 months ago

The same problem building apk on Ubuntu 22.04.4 LTS.

Without adding numpy to requirements.txt and without setting the variable SERIOUS_PYTHON_P4A_DIST, the built app shows an error after opening, as expected.

After setting the variable, in my case:

export SERIOUS_PYTHON_P4A_DIST=~/.local/share/python-for-android/dists/mydist

and without adding numpy to requirements.txt, the app opens on Android but shows only an empty screen (no errors, no content).

After setting the variable and adding numpy to requirements.txt, the error described above occurs during the build process:

The Meson build system
      Version: 1.2.99
      Source dir: /tmp/pip-install-n8ere989/numpy_c7624fe3d7e946868f35ded5a5580988
      Build dir: /tmp/pip-install-n8ere989/numpy_c7624fe3d7e946868f35ded5a5580988/.mesonpy-51jb9jq0
      Build type: native build
      Project name: NumPy
      Project version: 1.26.4

      ../meson.build:1:0: ERROR: Unknown compiler(s): [['Cannot_compile_native_modules']]
      The following exception(s) were encountered:
      Running `Cannot_compile_native_modules --version` gave "[Errno 2] No such file or directory: 'Cannot_compile_native_modules'"
ndonkoHenri commented 1 month ago

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