flet icon indicating copy to clipboard operation
flet copied to clipboard

bug: Cannot build APK with `pyaes` dependency in Flet.

Open nimaxin opened this issue 1 month ago • 1 comments

Duplicate Check

  • [x] I have searched the opened issues and there are no duplicates

Describe the bug

When I try to build an APK using Flet 0.28.3 with pyaes as a dependency, the build fails:

(.venv) xin@flet-build-lab:~/flet-pyaes-issue$ flet build apk
[23:03:17] Flutter 3.29.2 installed ✅                                                                                                                                     
           JDK installed ✅                                                                                                                                                
           Android SDK installed ✅                                                                                                                                        
[23:03:19] Running package command                                                                                                                                         
           Extra PyPi indexes:                                                                                                                                             
           Created temp directory: /tmp/serious_python_tempPRRUTP                                                                                                          
           Copying Python app from /home/xin/flet-pyaes-issue/src to a temp directory                                                                                      
           Configured Android/arm64-v8a platform with sitecustomize.py                                                                                                     
           Installing  with pip command to /home/xin/flet-pyaes-issue/build/site-packages/arm64-v8a                                                                        
                                                                                                                                                                           
           ERROR: Could not find a version that satisfies the requirement pyaes (from versions: none)                                                                      
           ERROR: No matching distribution found for pyaes                                                                                                                 
                                                                                                                                                                           
[23:03:21] Doctor summary (to see all details, run flutter doctor -v):                                                                                                     
           [✓] Flutter (Channel stable, 3.29.2, on Ubuntu 22.04.5 LTS 5.15.0-151-generic, locale en_US.UTF-8)                                                              
           [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)                                                                                
           [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)                                                                               
               ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.                                                                                 
           [✗] Linux toolchain - develop for Linux desktop                                                                                                                 
               ✗ clang++ is required for Linux development.                                                                                                                
                 It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/                             
               ✗ CMake is required for Linux development.                                                                                                                  
                 It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/                            
               ✗ ninja is required for Linux development.                                                                                                                  
                 It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases    
               ✗ pkg-config is required for Linux development.                                                                                                             
                 It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from                                                   
           https://www.freedesktop.org/wiki/Software/pkg-config/                                                                                                           
           [!] Android Studio (not installed)                                                                                                                              
           [✓] Connected device (1 available)                                                                                                                              
           [✓] Network resources                                                                                                                                           
                                                                                                                                                                           
           ! Doctor found issues in 3 categories.                                                                                                                          
                                                                                                                                                                           
Error building Flet app - see the log of failed command above.

I can install pyaes manually with pip install pyaes, but it uses the legacy setup method:

(.venv) xin@flet-build-lab:~/flet-pyaes-issue$ pip install pyaes
Collecting pyaes
  Using cached pyaes-1.6.1.tar.gz (28 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pyaes, since package 'wheel' is not installed.
Installing collected packages: pyaes
  Running setup.py install for pyaes ... done
Successfully installed pyaes-1.6.1

It seems Flet cannot handle packages installed this way, even though pyaes is pure Python.

Code sample

# main.py
import flet as ft
import pyaes  # or any package installed via setup.py install

def main(page: ft.Page):
    page.add(ft.Text("Hello World"))

ft.app(target=main)

To reproduce

  1. Create a Flet project.
  2. Add pyaes to pyproject.toml dependencies:
dependencies = [
  "flet==0.28.3",
  "pyaes"
]
  1. Run flet build apk.
  2. See error: No matching distribution found for pyaes.

Expected behavior

Flet should detect and include packages installed via legacy setup.py install, allowing all pure Python packages to be built into APKs successfully.

Screenshots / Videos

No response

Operating System

Linux

Operating system details

Ubuntu 22.04.5 LTS

Flet version

0.28.3

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

No response

Additional details

This affects all packages that don’t provide a wheel. It seems related to how Flet packages dependencies for Android. Installing wheel or building a wheel might be a temporary workaround, but the build system should ideally handle these packages automatically.

nimaxin avatar Nov 22 '25 23:11 nimaxin

Yeah, the package is a pure python package, but because it ships source distribution (and not wheels, as common), you need to use an additional option when building: --source-packages.

I gave the latest pre-release a try and it worked. Please give it a try and let know how it works out.

src/main.py
import flet as ft
import pyaes


def main(page: ft.Page):
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    page.add(ft.Text(f"Pyaes version: {pyaes.VERSION}", size=30))


ft.run(main)
pyproject.toml
dependencies = [
    "flet >=0.70.0.dev0",
    "pyaes",
]

[dependency-groups]
dev = [
    "flet[all] >=0.70.0.dev0",
]

[tool.uv]
prerelease = "allow"

[tool.flet]
source_packages = ["pyaes"]     # --source-packages in CLI

[tool.flet.app]
path = "src"
Screenshot

after running the app with flet debug

Image

ndonkoHenri avatar Dec 17 '25 02:12 ndonkoHenri