aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 3551ad0ccfc0356517655a392e985b9db78bc253 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# tryfle A look at flet for building cross platform apps

"DISCLAIMER: This repository contains the test app for a framework called flet and this readme. The readme is also me just trying to see whether or not its worth working with and jotting enough down to come back to it if it is. It is by no means meant to be complete or coherent, just a test case and a running set of notes."

My team lead got all exited about this thing called flet for whipping out python data at a glance (using it as a web app) I had never heard of it but I have spent years developing multiplatform gui applications using wxpython so I thought I would give it a try.

Most of the stuff that follows is based on the default app that you get when you install flet and 'flet create' an app. it is a box with a number and a button that increments it.

## The setup

I created this repository as an empty repository. 
Then I did something similar to the following

```sh
git clone git@github.com:feurig/tryfle.git
cd tryfle
flet create --project-name=hello
git add pyproject.toml src
git status
git commit -a -m "This is our starting point"
git push
```

## Flet on macos (tahoe)

Installing and trying flet on macos was relatively painless.

### trying flet run on macos

``` sh
git clone git@github.com:feurig/tryfle.git
cd tryfle
flet run
```

![fletrunning](docs/images/flet-run.jpg)

Which is pretty damned cool!

### flet build for macos

We are supposed to be able to build binaries so....

```sh
flet build macos -v
```

#### FAILS

flet build uses a pile of google provided ruby named flutter. One of its dependencies is cocoapods. Which doesn't play well with the arcane version of ruby that is still the default on macos tahoe.

And installing ruby 3 or 4 on macos is just a pile.

```sh
sudo gem install cocoapods
gem install ffi -v 1.17.4
sudo gem install ffi -v 1.17.4
# FAILS !!!!
brew install ruby
brew install ruby3
brew install ruby@3.4
type ruby
which ruby
ruby --version
brew install ruby
brew install ruby@3.4
echo "eval $(/opt/homebrew/bin/brew shellenv)" >> ~/.zprofile
eval $(/usr/local/bin/brew shellenv)
# FAILS !!!! then some googles....
brew install rbenv
/usr/local/bin/rbenv install --list-all
brew show ruby
brew info ruby
/usr/local/bin/rbenv install 4.0.0
# FAILS !!!!
/usr/local/bin/rbenv install 3.3.11
# FAILS !!!!
brew install openssl
brew reinstall openssl
/usr/local/bin/rbenv install 4.0.0
# FAILS !!!!
brew reinstall libopenssl
brew info ruby
/usr/local/bin/rbenv install 4.0.3
# FAILS !!!! ...more googles...
brew install openssl@1.1
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"\nrbenv install 3.0.6
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)"\n\nrbenv install 3.3.3
# FAILS !!!!
```

#### DOH! homebrew has a cocoapods

```sh
brew install cocoapods
brew link --overwrite cocoapods
```

#### Neeto!!!

![hello app](docs/images/hello-app.jpg)

#### Pushing the mac a little further.

So for fun I found a CC hello world icon ![icon](src/assets/icon.png) 

and replaced the flet one.
The [license with the attribution](src/assets/LICENSE.md) is
is in the repo with under src/assets.

```sh
feurig@pj tryfle % flet build macos -v
[19:39:58] Run subprocess: ['/Users/feurig/flutter/3.41.4/bin/flutter', '--version',
...
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Successfully built your macOS bundle! 🥳 Find it in build/macos directory. 📁                  │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
feurig@pj tryfle % rm -rf ~/Applications/hello.app
feurig@pj tryfle % mv build/macos/hello.app ~/Applications
```

The flet icon still shows up still shows up in the task bar.
But it looks and feels more like a mac app.

![new icon](docs/images/hello-app2.jpg)

### cross compiling on the mac (FAIL)

I have a few raspberry pi's which have displays and which I plan to embed in various things. Throwing up a nice display quickly is very appealing. So my first thought was to cross compile from the mac to linux. (I knew this was a long shot).

```sh
feurig@pj tryfle % flet build linux --arch=aarch64
[21:55:36]                Build Platform Matrix
           ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
            Command                         Platform                   ┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
            flet build windows               Windows                   ├──────────────────────────┼───────────────────────┤
            flet build macos                  macOS                    ├──────────────────────────┼───────────────────────┤
            flet build linux                  Linux                    ├──────────────────────────┼───────────────────────┤
            flet build web            macOS, Windows, Linux            ├──────────────────────────┼───────────────────────┤
            flet build apk            macOS, Windows, Linux            ├──────────────────────────┼───────────────────────┤
            flet build aab            macOS, Windows, Linux            ├──────────────────────────┼───────────────────────┤
            flet build ipa                    macOS                    ├──────────────────────────┼───────────────────────┤
            flet build ios-simulator          macOS                    └──────────────────────────┴───────────────────────┘
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ You can't build                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────╯
```

### cross compiling on debian (FAIL)

Ok so I really don't want to build on an underpowered little device when I have a relatively beefy linux box in the basement. I will spare you the details of installing the toolchain and insane prereqs.

```sh
feurig@nick:~/Projects/tryfle$ PATH=$PATH:/tank/home/feurig/flutter/3.41.4/bin flet build linux --arch=aarch64
[21:46:37] Created app shell [21:46:38] Packaged Python app [21:46:44] Customized app icons [21:46:47] Generated app icons [21:46:55] Resolving dependencies...
...blah blah blah
           Building Linux application...

           ERROR: Target dart_build failed: Error: Failed to find any of  in
           LocalDirectory: '/usr/lib/llvm-19/bin'
           Build process failed
... more blah blah ... 

╭───────────────────────────────────────────────────────────────────────────────────────╮
│ Error building Flet app - see the log of failed command above.                        │
╰───────────────────────────────────────────────────────────────────────────────────────╯
feurig@nick:~/Projects/tryfle$ ls -lsa /usr/lib/llvm-19/
total 48
 4 drwxr-xr-x  8 root root  4096 Apr 27 14:58 .
 4 drwxr-xr-x 73 root root  4096 Apr 30 16:40 ..
 4 drwxr-xr-x  2 root root  4096 Apr 27 14:57 bin
 4 drwxr-xr-x  4 root root  4096 Apr 27 14:58 build
 0 lrwxrwxrwx  1 root root    14 Jun 14  2025 cmake -> lib/cmake/llvm
 4 drwxr-xr-x  2 root root  4096 Apr 27 14:58 include
20 drwxr-xr-x  6 root root 20480 Apr 27 14:58 lib
 4 drwxr-xr-x  2 root root  4096 Apr 27 14:49 libexec
 4 drwxr-xr-x  8 root root  4096 Apr 27 14:58 share
```

flutter bitches about something that is clearly there.

### compiling on debian (FAIL)

Lets see if it even compiles natively

```sh
feurig@nick:~/Projects/tryfle$ PATH=$PATH:/tank/home/feurig/flutter/3.41.4/bin flet build linux
[20:51:26] Packaged Python app [20:51:33] Building Linux application...

           ERROR: Target dart_build failed: Error: Failed to find any of  in
           LocalDirectory: '/usr/lib/llvm-19/bin'
           Build process failed
... blah blah blah ...
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ Error building Flet app - see the log of failed command above.                        │
╰───────────────────────────────────────────────────────────────────────────────────────╯
```

NOPE.

### Running on debian

Ok so it wont compile will it run?

#### running on x (FAIL)

The debian machine is a server so we ssh in and X-forward.

![really dark mode](docs/images/debianxrun.jpg)

#### running on x using 'flet run --web' and google chrome

This more or less works so you can still run it on debian

![chrome](docs/images/debianrunxweb.jpg)

#### JUST DONT PUSH THE INSTALL BUTTON!

Pushing the install button puts the app in a really nice window where none of the window controls work except for full screan which blacks out most of the screen and wont go back. Maybe it works on a desktop but YUK!!!

![wtf](docs/images/whatthefuck.jpg)

### Running on raspberry pi

Since running on the raspberri pi is good enough for our use case we will go there first.

![long narrow](docs/images/raspirun.jpg)

That works!

### compiling on rasberry pi (FAIL)

On a rasberry pi, which is an arm processor, flet installed an intel binary. 

That is gobsmackingly stupid.

```sh
feurig@five:~/Projects/tryfle $ flet build linux --arch=aarch64
[21:27:00] 1 Failed to validate Flutter version.
           Flutter SDK not found or invalid version installed.
(     ) Initializing linux build...
Flutter SDK 3.41.4 is required. It will be installed now. Proceed?   [y/n] (y): y
[21:27:03]
           /home/feurig/flutter/3.41.4/bin/internal/shared.sh: line 273:
           /home/feurig/flutter/3.41.4/bin/cache/dart-sdk/bin/dart: cannot execute binary
           file: Exec format error
           /home/feurig/flutter/3.41.4/bin/internal/shared.sh: line 273:
           /home/feurig/flutter/3.41.4/bin/cache/dart-sdk/bin/dart: Success

           /home/feurig/flutter/3.41.4/bin/internal/shared.sh: line 273:
           /home/feurig/flutter/3.41.4/bin/cache/dart-sdk/bin/dart: cannot execute binary
           file: Exec format error
           /home/feurig/flutter/3.41.4/bin/internal/shared.sh: line 273:
           /home/feurig/flutter/3.41.4/bin/cache/dart-sdk/bin/dart: Success

╭───────────────────────────────────────────────────────────────────────────────────────╮
│ Error building Flet app - see the log of failed command above.                        │
╰───────────────────────────────────────────────────────────────────────────────────────╯
feurig@five:~/Projects/tryfle $ file /home/feurig/flutter/3.41.4/bin/cache/dart-sdk/bin/dart
/home/feurig/flutter/3.41.4/bin/cache/dart-sdk/bin/dart: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a6c2875adfaa96a24e720daaf5261c03f2e7d05f, stripped
feurig@five:~/Projects/tryfle $
```

### Windows
I don't do windows _(unless someone is paying me enough to)_

On the other hand if Windows works as well as the mac I would happily excuse the linux fails since it still works well enough to be useful and there is a lot of windows out there.

My friend tested this on a windows system with the full visual studio suite installed. It ran using flet run but, like the native linux build, could not find the installed tools. 

https://gist.github.com/tlockney/a677247beeedccc293f321a71528f113

## Initial conclusion

It's a mixed bag so far. Meh.

It has its uses. Probably the best of which was the one that my team lead was happy about (html display of columnar data at a glance without having to convert it to a spreadheet). I did go down the rabbit hole of trying to figure out some of the FAILS, but much like it's ability to build and package code, the googles are getting more and more cluttered with slop and there is only so much time.

For now, I think it's got a small place in my toolbox. 

## References

https://dev.to/flet/tutorial-build-and-package-a-multi-platform-desktop-app-in-python-3ncc