flet icon indicating copy to clipboard operation
flet copied to clipboard

Can't generate apk when add numpy

Open ahmedashraf344 opened this issue 1 year ago • 5 comments

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] + /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_qa99V4/python/bin/python3 /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22/vendored-meson/meson/meson.py setup /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22 /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22/.mesonpy-ytswz4qn -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22/.mesonpy-ytswz4qn/meson-python-nativ e-file.ini The Meson build system Version: 1.2.99 Source dir: /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22 Build dir: /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22/.mesonpy-ytswz4qn 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'"
  
  A full log can be found at 

/private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-install-itdh_2d_/numpy_9345a9edeb914d39b49668b4e56f5f22/.mesonpy-ytswz4qn/meson-logs/meson-log.txt

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× 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 %

ahmedashraf344 avatar Feb 23 '24 02:02 ahmedashraf344

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

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

ahmedashraf344 avatar Feb 23 '24 17:02 ahmedashraf344

I have the same problem but to SQLAlchemy ORM :/

MoreiraCristiano avatar Mar 09 '24 13:03 MoreiraCristiano

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'

prodat1 avatar Apr 18 '24 13:04 prodat1

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'"

aniqu18 avatar Apr 21 '24 13:04 aniqu18