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.38k stars 446 forks source link

PyTorch 2.4.1 wont install on Flet Build for macOS (regression 0.25dev) #4270

Open ap4499 opened 1 week ago

ap4499 commented 1 week ago

Duplicate Check

Describe the bug

On the latest dev build of Flet 0.25, torch==2.4.1 cannot be installed when using Flet Build.

Code sample

Code #main.py ```python import torch import flet ``` #requirements.txt ``` flet==0.25.0.dev3598 torch==2.4.1 ```

To reproduce

  1. Setup scripts.
  2. Run Flet build command as below:
export PATH=$HOME/development/flutter/bin:$PATH

flet build macos --project "Demo" --product "Demo" --org "com.ABC" --company "Demo" --build-version "1.0.0" -vv

Expected behavior

Successful install.

Screenshots / Videos

Captures [Upload media here]

Operating System

macOS

Operating system details

MacOS 15.0.1

Flet version

flet==0.25.0.dev3614

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs ``` console ( ● ) Packaging Python app ⏳... ERROR: Could not find a version that satisfies the requirement torch==2.4.1 (from versions: 2.2.0, 2.2.1, 2.2.2) ERROR: No matching distribution found for torch==2.4.1 ```

Additional details

The above works when using Flet==0.24.1.

Note, in the above, the code is light as Torch is not being used for anything - this is just illustrating the issue with the Build() process.

FeodorFitsner commented 6 days ago

Trying to build macOS app with torch==2.4.1 and detailed log gives this error:

(   ●  ) Packaging Python app ⏳... Configured Darwin/x86_64 platform with sitecustomize.py
Installing [flet==0.25.0.dev3614, torch==2.4.1] with pip command to /var/folders/39/r38wl7vj2ds6bmcw9sfhsgf80000gn/T/serious_python_tempg1CO8p/__pypackages__/x86_64
(     ●) Packaging Python app ⏳... ERROR: Could not find a version that satisfies the requirement torch==2.4.1 (from versions: 2.2.0, 2.2.1, 2.2.2)

Packaging macOS has been improved in Flet 0.25 and now, by default, it's trying to create a universal app, i.e. include both arm64 and x86_64 dependencies. Here we see that it cannot find x86_64 wheels for torch 2.4.1 and we can confirm that on this page - only macOS arm64 wheels are available: https://pypi.org/project/torch/2.4.1/#files

There is a new --arch option for flet build command that tells it to build only a specific architecture. Currently works only with macOS builds.

Run flet build macos --arch arm64 ... and it will package just fine. Resulting bundle will be able to run on "M" CPUs only.

Let's keep this issue open as a reminder to update docs.