bug: flet build windows gets stuck on packaging python app; and extension template generation issues
Duplicate Check
- [x] I have searched the opened issues and there are no duplicates
Describe the bug
I have been following the documentation on creating user extensions for flet step-by-step from here. As of right now, I have managed to work my way through the following steps successfully[assuming that the flet extension is just called flet-wvr] :
- created a virtual environment within the project folder.
- activated the virtual environment using .venv\Scripts\activate.bat
- installed flet[all] {version: 0.28.3 according to
pip show} usingpip install flet[all]on it. - ran the command suggested by the docs with the name for my extension in place -
flet create --template extension --project-name flet-wvr. - cd-ed into the newly created examples directory, and further more into the flet_wvr_example directory within it.
and, this is where the problems begin. Firstly, I have noticed an issue with the way the pyproject.toml is generated, which causes an unbalanced quotes error, it'd be nice if this was fixed so that the template generated paths with \\ instead of just \. This would prevent the confusion a new developer might face when they encounter this issue. I had ended up doing this manually though and that resulted in the elimination of the unbalanced quotes error on my end. So, with that out of the way, lets move on to the other issue I've been facing -
trying to run flet build windows -v or flet build windows or flet build windows -vv are all met with -
- an attempt at the installation of flutter, which is always successful and finishes with the status
Flutter 3.29.2 installed ✅. - an attempt at running a subprocess that uses the dart.bat from the installed flutter alongside serious_python, to package the app. this is the step that fails to ever finish. it gets stuck on Packaging Python app... forever. In verbose mode it doesn't show any logs about where it is getting stuck either, the last log shown during verbose mode building process is the attempt to run a subprocess with the dart.bat and serious_python args, after that it just gets stuck forever. I have tested and waited for this to finish for 2+ hours at some point and I am very positive this is not an internet speed issue or anything of that kind. A screenshot of how it looks with the
-vv[most detailed output I could possibly provide] will be attached to this issue.
To fix this issue and debug it, I have tried the following:
- deleted the build dirs created inside the examples/flet_wvr_example folder and the one created outside, alongside the egg info file from src -> this does not change anything, building it again causes the same issue to occur. Nothing is changed in the slightest.
- deleted flutter itself from my local environment, I do not use flutter separately for development -- so the original flutter installation was also due to flet, and wasn't manual, but I deleted it to let flet install a newer version of Flutter, this has also failed to lead to any improvements in the situation. This just makes flet wait for longer to first install flutter before it starts building the package, and then it gets stuck in the exact same way.
- tried deleting the entire venv and project directory and starting from scratch -- also does not work, this problem seems to be persistent across venvs.
- tried downgrading[using flet == 0.26.0 instead], this leads to different verbose output messages, but the build process still gets stuck on the "Packaging Python app..." stage. The last verbose output includes flet trying to install collected packages.
- tried using uv instead of pip to make venvs and run these commands -- leads to the same exact issue, no change observed.
- tried installing a newer version of python, the latest one infact, though the old version I had was 3.12, now I have 3.13.5 -- this did not change anything either.
- tried updating my visual studio development with c++ tools, this has also not lead to any difference in the build command output.
- i've tried running build with the
--cleanup-appand--clear-cacheoptions with also no difference observed in the behavior. - I've tried using the command prompt in admin mode, whilst following the same exact steps outlined previously -- this also leads to no change of behavior.
- tried using WSL[Windows Subsystem for Linux] to no avail, which should've been obvious right away, considering the fact that
flet build windowsis only supported on Windows and no other platform including linux, so this was just a shot in the dark. this method funnily enough worked in the past when trying to build for android, but it is sad that I cannot use it to bypass the issues I have been facing, this time around. - tried using AI to figure out if there were any solutions it could think of, GPT just straight up gave me a summary of it's google searches about the topic, that were very much unrelated, keep in mind that I am running a very minimal flet template, from the docs, and that there should not be any dependency or code related issues, cuz this is all pre-generated and has worked for multiple other users. Gemini on the other hand, did help me debug this quite a bit, and the steps I took to debug it more deeply have been outlined in the next few points.
- I tried using ProcMon[Process Monitor -- A tool made to be used to see all the low level events taking place as a result of different apps on the device], I used two major filters:
12.1. Process Name is python.exe 12.2. Process Name is flet.exe
I decided to limit the filters to just these two, after testing out the results with more. These filters were sufficient enough to fetch the events taking place at a lower level due to the flet build command.
A brief/short description of my analysis of the ProcMon logs along with Gemini's help would be that -- A bunch of QueryInformation events were being issued by python.exe for addresses/paths that corresponded to pip-related files. A bunch of these events were SUCCESSes, and alot of others in between were BUFFER OVERFLOWs. This would keep going for a while, until at the very end, python.exe just started issuing CloseFile events for most of the previously accessed paths and then it'd get stuck in a loop trying to make a TCP connection -- create a thread -- and then exit the thread, repeatedly with nothing else happening while the build was still stuck on the "Packaging Python app..." step. I will attach some of my screenshots of the events described here, alongside this issue. From the analysis of all these events, what I ended up inferring; using some help from Gemini -- was that the issue being faced here, was related to long paths on windows, hence why the BUFFER_OVERFLOW results were coming in for a bunch of the events. I even tried switching my development to a folder inside the C: dir, instead of it being in subdirs, but even then the same issues were faced. I tried enabling LongPath support for windows by modifying the Registry using regedit on windows and set the value of LongPathsEnabled to 1 and restarted my computer, with not alot of change in the build process.
Description of the build directories :
-
External[Outside the
examplesdirectory]: It contained an empty folder by the name ofbdist.win-amd64and alibfolder withflet_wvrandflutterbeing subdirs within thelibfolder that contained the python and flutter files forflet_wvrrespectively. -
Internal[Inside the
examples/flet_wvr_exampledirectory]: It contained three folders -- namely.hash,flutterandsite-packages; withsite-packagesbeing completely empty[gemini described this to be the major issue, it said that the build process was successful at setting up the extension but got stuck at packaging the flet app alongside the python environment, just wanted to leave this in, incase it'd be of any help],.hashcontained a file named template-1 andfluttercontained a bunch of flutter related stuff in it. -
This was not really a fix for this issue, but rather a workaround, but it did indicate that the guess about the problem being caused due to path lengths might be right -- I tried using github-actions to build the template, it finished with success and created an artifact -- which was a .zip of the state the repo would've been in, if flet build was to be run locally, as instructed in the docs -- but when trying to unzip it on my platform, windows gave me the following error:
Error 0x80010135: Path too long.. So my development has basically been put to a halt entirely due to this issue; and I cannot even use workarounds to be able to develop it still.
I have already tried asking for help on the flet discord server, to no avail, alot of the people on there tried to help, but alot of them haven't faced this issue. This issue seems to be unique to certain windows 11 devices. I cannot really afford to try and reinstall windows, and it shouldn't have to be like that, I should be able to use a framework and fix the issues related to it, without having to reinstall my very operating system.. I have spent countless hours trying to find a fix for this, and I really hope that this issue will be looked at and answered with immediate attention. I do not ask for much, I know this is a free service you guys are providing to the community and I appreciate that but I would still like for it to be less error-prone for it to be usable enough on my front. Thanks, I hope this gets resolved fast! I'll try to see if I can fix the template pyproject.toml generation issue with the backslashes in a PR.
Code sample
Code
N/A [just built the template, no explicit code has been written]
To reproduce
This seems to be a device/installation specific issue, and not all devices can reproduce this for some reason, but here are the steps I took to have come across this issue -
- create a virtual environment within the project folder.
- activate the virtual environment using .venv\Scripts\activate.bat
- instal flet[all] {version: 0.28.3 according to
pip show} usingpip install flet[all]on it. - run the command suggested by the docs with the name for my extension in place -
flet create --template extension --project-name flet-wvr. - cd into the newly created examples directory, and further more into the flet_wvr_example directory within it.
- run
flet build windows -vv. - wait for the flutter installation to finish and observe the behavior of the
Packaging Python app..., if your device has the [whatever thing is causing this issue] -- it should get stuck at running the subprocess and not finish.
Expected behavior
I expected the app to finish building within 10 mins max, that is the feedback I've gotten from other developers working with flet. But instead it just gets stuck on the "Packaging Python app..." step.
Screenshots / Videos
Captures
Operating System
Windows
Operating system details
Windows 11
Flet version
0.28.3
Regression
I'm not sure / I don't know
Suggestions
- To fix the template pyproject.toml generation issue, just make it generate with paths having \ in general, since they are gonna be escaped to \ anyways.
- I am very certain that the
flet build windows -vvissue has something to do with the path limit on windows, despite me having enabled long paths using the registry variable, it still gave me the buffer overflow issue at the smallest path i could possibly get to[while for most users it works fine even with longer paths, or it doesn't work altogether]. It also gave me the same Path too long issue whilst unzipping my pre-built github actions based zip file. So -- a fix would need to prolly try and make the command independent of the length of paths; And, maybe working on trying to rework the template structure, such that it doesn't look for files that deep into the project structure.
Logs
Logs
[13:27:12] Ensure Flutter has desktop support enabled
Run subprocess: ['C:\\Users\\ketch\\flutter\\3.29.2\\bin\\flutter.bat', 'config', '--no-version-check',
'--suppress-analytics', '--enable-windows-desktop']
[13:27:13] Setting "enable-windows-desktop" value to "true".
You may need to restart any open editors for them to read new settings.
[13:27:14] Flutter 3.29.2 installed ✅
Flutter executable: C:\Users\ketch\flutter\3.29.2\bin\flutter.bat
Dart executable: C:\Users\ketch\flutter\3.29.2\bin\dart.bat
Run subprocess: ['C:\\Users\\ketch\\flutter\\3.29.2\\bin\\dart.bat', 'run', '--suppress-analytics',
'serious_python:main', 'package', 'C:\\adi_dev\\flet_extensions\\flet_wvr\\examples\\flet_wvr_example\\src',
'--platform', 'Windows', '-r', 'flet-wvr @ file://C:\\adi_dev\\flet_extensions\\flet_wvr', '-r',
'flet>=0.28.3', '-r', '--no-cache-dir', '--exclude', 'build', '--cleanup-packages', '--verbose']
(● ) Packaging Python app...
Additional details
For the most part, I have already gone over this and stressed this enough, but this happens only on some devices and not on others. It might just be a lack of knowledge on my end, but I'd like to know about how to fix this either way, and if it helps others out it'd be even better, which is why I have decided to post this as an issue.