Latest / Talk Python To Me / #494: Update on Flet: Python + Flutter UIs
Transcript
- 0:00As Python developers, we're incredibly lucky to have over half a million packages that we can choose to build our applications from over at PyPI. However, when it comes to choosing a UI framework, the options get narrowed down very quickly. Intersect those choices with the ones that work on mobile, and you have a very short list. Flutter is a UI framework for building desktop and mobile applications, and is in fact the one that we use to build the Talk Python courses app, which you'll find at talkpython.fm/apps. That's why I'm so excited about Flet. Flet is a Python UI framework that is distributed and executed on the Flutter framework, making it possible to build mobile apps and desktop apps with Python. We have Fedor Fitzner back on the show after he launched his project a couple of years ago to give us an update on how close they are to a full featured mobile app framework in Python. This is Talk Python To Me, Episode 491 recorded December 17th, 2024.
- 0:59- Are you ready for your host, please?
- 1:01- You're listening to Michael Kennedy on Talk Python To Me.
- 1:05Live from Portland, Oregon, and this segment was made with Python.
- 1:11- Welcome to Talk Python To Me, a weekly podcast on Python.
- 1:14This is your host, Michael Kennedy.
- 1:16Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython, both accounts over at fosstodon.org.
- 1:25And keep up with the show and listen to over nine years of episodes at talkpython.fm.
- 1:30If you want to be part of our live episodes, you can find the live streams over on YouTube.
- 1:34Subscribe to our YouTube channel over at talkpython.fm/youtube and get notified about upcoming shows.
- 1:40This episode is sponsored by Posit Connect from the makers of Shiny.
- 1:45Publish, share, and deploy all of your data projects that you're creating using Python.
- 1:49Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs.
- 1:56Posit Connect supports all of them.
- 1:58Try Posit Connect for free by going to talkpython.fm/posit.
- 2:03P-O-S-I-T.
- 2:05And it's also brought to you by us over at Talk Python Training.
- 2:09Did you know that we have over 250 hours of Python courses?
- 2:13Yeah, that's right.
- 2:14Check them out at talkpython.fm/courses.
- 2:16Flash courses.
- 2:17Peter, welcome back to Talk Python To Me.
- 2:20Awesome to have you here.
- 2:20>> I'm Michael, fellow Python developers.
- 2:23>> Yeah, it's real good to have you here.
- 2:25I know that there was a lot of excitement about Flutter.
- 2:28In fact, I got a message just a couple of weeks ago from somebody saying, "Is Flutter what you use to write your mobile apps?" And I'm like, "No, because that was a while ago." And I kind of wish that was an option, but it wasn't an option for us at the time.
- 2:42Anyway, I think Flutter is going strong.
- 2:46I think there's a lot of excitement around it.
- 2:48And certainly there's an excitement for building mobile applications in Python.
- 2:53Yeah.
- 2:53Flutter is getting stronger and stronger.
- 2:55You know, like recently I saw there was an attempt to fork Flutter, you know, because like it was a feeling in the community that it's not moving anywhere.
- 3:06You know, but I don't believe that even that guy mentioned that there are like 50 developers working on Flutter right now at Google.
- 3:15So yeah, Flutter is getting better and better and their release cycle is pretty awesome, you know?
- 3:21Sometimes it's really hard to catch up, but still, yeah.
- 3:24- That can actually be a problem.
- 3:25I just updated Flutter on my Mac mini.
- 3:29I had out of date CocoaPods and Ruby and there's a whole tool chain that people need to know about.
- 3:35Maybe we can talk a little bit about the tool chain, but yeah, you're constantly chasing versions and releases and updates.
- 3:42You've got Android Studio versions.
- 3:44You've got Xcode.
- 3:46There's a lot there.
- 3:46We recently started using Flutter version manager FBM and it's pretty good.
- 3:52Yeah, because the updating is so fast, you know, it's really hard to catch up.
- 3:58This portion of Talk Python To Me is brought to you by the folks at Posit.
- 4:02Posit has made a huge investment in the Python community lately.
- 4:05Known originally for RStudio, they've been building out a suite of tools and services for team Python.
- 4:12Today, I want to focus on hosting your Python-based data science workloads.
- 4:17This includes dashboards, reports, plots, interactive web apps, all the way to custom Flask and Django apps.
- 4:24Their service is Posit Connect.
- 4:26Posit Connect makes it easy for data scientists to share work built with Python code.
- 4:31If you have a Streamlit app, Dash, dashboard, Plotly, interactive plot, a FastAPI service, or even a Quarto report, just give Posit Connect the code it needs to maintain the asset and Connect automatically does the rest.
- 4:45Connect will manage your APIs and serve your interactive apps for you.
- 4:49And if you want, you can update your reports and dashboards on a scheduled basis.
- 4:53That's right, no need to explain to the stakeholders why that dashboard or plot stopped updating last week.
- 4:59You get to focus on your data science and leveraging your skillset while Connect makes you look good, keeping your code running and private.
- 5:07With Connect, you get a private URL on your Connect server, ensuring that your asset is continuously available to your shareholders.
- 5:14And you can control which users have access to the asset.
- 5:18Let Posit Connect handle the delivery and DevOps involved in sharing your work.
- 5:22You focus on what you do best.
- 5:25So if you work on a data science team, you owe it to you and your org to check out Posit Connect.
- 5:31Visit talkpython.fm/connect today and get a three-month free trial to see if it's a good fit.
- 5:37That's talkpython.fm/connect.
- 5:40The link is in your podcast player show notes.
- 5:42Thank you to Posit for supporting Talk Python To Me.
- 5:46Maybe a quick introduction.
- 5:47It has been, you know, we, I guess it's worth giving a shout out back in summer 2022, you were on the show when Flutter first came out to tell everyone about, sorry, when Flutter first came out to tell everyone about Flut and how it's basically Flutter plus Python for UI, but it's been a while.
- 6:06So, you know, tell people quickly who you are and we can get into the project.
- 6:11My name is Peter Fitzner.
- 6:13I'm the founder and developer of a flat framework, like Flutter for Python, for Flutter, yeah, it's been two and a half years since we released the first version. It's not like the first release of web and since that time we gained really great traction. To my mind like we got 12,000 stars on GitHub, 72 contributors, 5k members on discord channel and I found the statistics for PyPy. It's like almost 3 million downloads from PyPy of web package. So It's a great community, great people, a lot of feedback, a lot of issues.
- 7:03So it's pretty nice.
- 7:04That's awesome.
- 7:04And it definitely seems like it's going strong.
- 7:07I do think maybe it's worth actually talking a bit about what Flutter is before we dive into Python for Flutter with Flut, right?
- 7:15Give people a quick sense of what is this Flutter thing that we're talking about?
- 7:18Flutter is a cross-platform framework.
- 7:22It works for web, iOS, Android, and all desktop platforms.
- 7:28It allows you to write nice apps, really nice apps with great UI in Dart language.
- 7:34So you have to learn a new language.
- 7:37And Flutter is a framework.
- 7:40So it's like, it's not just UI, it's application framework.
- 7:44It has all the things to build the app.
- 7:49There's the language, which is Dart, not Flutter, but then Flutter has all the UI widgets and the mechanisms, but it also is a whole series of build tools that will take that and create things that you can upload to the mobile app stores like app, Apple's app store or Google play or other places, right?
- 8:10Like desktop apps.
- 8:11So there's a bunch of layers to what Flutter really is.
- 8:15I think Also, the interesting part about Flutter is that it has a painted UI.
- 8:22So it started from the Skia engine and now they have their own engine in Palo Alto.
- 8:28So the UI is basically painted on the canvas.
- 8:32So it looks similar everywhere on every device.
- 8:36Like some frameworks, like for example React Native, they use native controls.
- 8:44But Flutter, it looks similar on every device.
- 8:48It's cool that it runs everywhere, but sometimes that can fall short.
- 8:52The biggest example of this for me is Java applications.
- 8:55When they have their own file browsing dialogue, you're like, Oh, this is clearly not a native sort of thing going on here.
- 9:01You know, on a, on a desktop situation, they don't look like windows dialogues.
- 9:05They don't look like macOS dialogues.
- 9:07They just look like Java dialogues.
- 9:08But so that can be a problem or limitation.
- 9:12But Flutter tries to look like the native controls.
- 9:17There's the, what do they call them?
- 9:18The Cupertino widgets and the material design widgets that, so it tries to adapt to the platforms it's on.
- 9:25That's why it's called Adaptive.
- 9:27Yeah.
- 9:28It's like this material design is built in, there is Cupertino controls.
- 9:33It also, I thought there are, think body packages for micro-OS and Windows like Fluent Design.
- 9:40By the way about dialogue, you know, if like this it's called file picker and it looks different for all platforms.
- 9:48So it's not always drawn like the UI.
- 9:51You can write like a native package, like using the underlying operating system API.
- 9:57So the dialogue looks pretty standard on macOS or windows.
- 10:02So yeah, it's not always so bad.
- 10:05It is for building apps all over the place, Flutter, but I would say it's real seems to be in the mobile app space, right?
- 10:12What do you think?
- 10:13Primarily iOS and Android?
- 10:15- Some recently asked me about like, why not React Native?
- 10:20So why you chose, and I went to Google, like, you know, like typing like Flutter, yes, React Native.
- 10:27And the interesting, it became more popular this year, 2024.
- 10:33So it's a little bit ahead of React Native, Flutter, in this year.
- 10:39So, yeah, so it's, it's according to stick with floor questionnaire, something like that.
- 10:46So it's gaining popularity.
- 10:48And I would say that yes, Flutter is more a mobile fast framework, despite they have awesome support for desktop platforms or web, it's still mobile first.
- 11:00And when we talked about Flutter, we should probably talk first about mobile devices and these benefits it brings to mobile development.
- 11:10That's right.
- 11:10It's a pretty interesting.
- 11:11I just looked on Stack Overflow trends.
- 11:13Let's see if I can find it.
- 11:15Yeah, look at that.
- 11:17The flutter is quite a bit higher than React Native.
- 11:20More than I expected.
- 11:22I'll put a link to that in the show notes for the Stack Overflow trends graph.
- 11:26What are the reasons behind that?
- 11:28Maybe it's ecosystem, maybe because it's pretty easy to find an extension to find some nice package on pub.dev.
- 11:40Maybe it's because it looks nice on both iOS and Android, and it looks similar, maybe.
- 11:48Maybe because Dart itself, I know people tend to criticize Dart, but I have some experience writing in JavaScript, TypeScript, and I can say that it was really nice learning Dart.
- 12:02It's a great language.
- 12:04And honestly, I know it's unpopular, but I feel it's kind of like better than JavaScript.
- 12:11It's just my opinion.
- 12:13So once you learn it, you can do everything.
- 12:16It's pretty nice.
- 12:17Maybe because of that.
- 12:18- Perhaps.
- 12:19And before we move off Flutter, just real quick, I wanna give a quick shout out to Lauren, the developer I worked with.
- 12:24He and I built the Talk Python courses apps in Flutter, which is why I have more than just like reading the docs experience in it.
- 12:32And those apps are going strong today.
- 12:35They're really great.
- 12:36Although I'm about to release a new version because you never stop releasing new versions, even if you think you're done and something changes behind the scenes with iOS or Android this time it's Android.
- 12:46Yeah.
- 12:46They go that all the time, that package that used to do this thing.
- 12:49It doesn't do it anymore.
- 12:50Like, Oh no.
- 12:51Okay.
- 12:52Okay.
- 12:52So that's the foundation that's Flutter.
- 12:55Flet.
- 12:55Tell us about Flet.
- 12:56I mean, you talked about the downloads, but like, where does it fit in this Flutter ecosystem?
- 13:00Flet is a native framework.
- 13:03As you can think, it's not just translated from Python to Dart.
- 13:08It's not just bindings for Flutter widgets, like PyQt, PySite, for example, but it's a standalone framework that uses Flutter for each UI.
- 13:23So Flet is an application framework.
- 13:25It's not just UI, and it uses Flutter to build each UI.
- 13:30I see. So people should think of it more as an independent UI and application framework for Python, not so much as a extension of Flutter into the Python world. Is that maybe the way to think of it?
- 13:43Right. We're still trying to go away from this label, you know, it's kind of, but it works really nice, like, right. Flutter, Epson, Python, it works pretty good, like in terms of a CEO, for example, but, but it's not true. Like It's a framework that uses, we could, I mean, potentially we could replace it with something else like this backend, you know, with like Compose or, you know, React Native, but no, it's Flutter.
- 14:12And it's really great.
- 14:15We, we, we have our own controls and it's not always one-to-one maybe, maybe, but it's like maybe of Flutter controls, they are built out of like multiple Flutter widgets.
- 14:29So we combine multiple Flutter widgets into controls.
- 14:34Because sometimes if you have some Flutter experience, sometimes you can notice that it's getting really...
- 14:42the UI getting really complex or, like, you know, later, like a lot of controls, like, wrapped into other widgets.
- 14:54Like, for example, if you want to center something, There is a center widget if you want to limit the size, the resize box.
- 15:03So Flag combines many widgets into more like controls and those are properties.
- 15:10So it's like it's cluttered in serve to Python developers in Pythonic way, I would say.
- 15:18On your, if people want to browse these controls, widgets, what do you want to call them?
- 15:22There's a whole controls section in your docs and I'll link to the docs, but the left it says controls and you go there, there's layout controls, navigation controls, you know, app bar type things that you might expect from standard mobile apps.
- 15:36And of course, like I sort of pointed out, you got the Cupertino versions and you've got the non Cupertino material design versions.
- 15:43So people can have a look at that and just get a sense for all the controls, but there are many, how many controls do you know off the top of your head?
- 15:49Oh, it's like a hundred plus I would say.
- 15:52And some really nice ones, right?
- 15:53Like you've got a web view, you've got maps, animations, charts.
- 15:59Yeah.
- 15:59Web view is, is not available for like all platforms at the moment.
- 16:04It's mostly for mobile and for my class, if I'm not mistaken.
- 16:08So yeah, it's kind of like there is a flat rule limitation right now that, for windows that doesn't allow to have a proper web view on windows platform.
- 16:18Oh yes.
- 16:19I remember that.
- 16:19That's yeah.
- 16:21What a hassle.
- 16:22There is work going on.
- 16:26You know, you were on the show before to talk about Flet and those were pretty early days then, right?
- 16:32To over two years ago.
- 16:34A lot.
- 16:35You've been, you're going strong.
- 16:36Like you said, you talked about the downloads and the contributors and stars and all that.
- 16:40That's awesome.
- 16:41So you, what have you all been up to?
- 16:44Where's this effort gone?
- 16:45Like what, what progress have you made?
- 16:46We started from a simple design.
- 16:49it was pre-built executable for every platform, mostly like for desktop platform, which is able to display all controls we have. And that executable was an ease part of a wheel, flat wheel you install. So if you do heap install flat, you install this executable with the Python API itself. But then we started getting more and more requests like asking Like, how would I put all this beautiful stuff to a mobile device?
- 17:23Or how do I do a standalone app?
- 17:26And, well, the answer is we should generate executable and Python should be part of it.
- 17:34Python, your program, set by the libraries you use for your program, all this stuff should be part of this executable.
- 17:42It's been a lot of work to produce a standalone package for desktop, for web, and for mobile.
- 17:51So Flutter is a good start for that.
- 17:54So the question was Python itself and third-party packages.
- 18:00So we decided that, like, okay, Python for desktop platform is really straightforward.
- 18:09You just take regular, basically regular Python and bundle it into your executable or application bundle and that's it.
- 18:19So it's pretty straightforward. For mobile devices, there is a challenge and we know that multiple projects when are working on this problem, like the most popular Kybee and Beware, Those guys started back, started solving this problem back in 2010, maybe 2012 if I'm not mistaken.
- 18:43And they did really great job and they're still doing great, you know.
- 18:49Yeah, I know Beware's got a lot of recent support as well through the Anaconda team, which is really great.
- 18:56We started from Kavi. I don't know, at that point, like two years ago, I thought that I saw maybe that Kavi is more popular And I decided to explore this way, whether Kyde could be used as a foundation for planning or we can grab portions of Kyde and make something different, you know.
- 19:19And it was good for the start, obviously.
- 19:24We managed to use Kyde tooling, like Python for Android, Python for iOS, and their command line and their libraries and their recipes to compile runtime, Python runtime and third party modules and use them in quantification.
- 19:45So, I mean, there was Kyvee.
- 19:47But you guys ended up moving off of it, right?
- 19:50Recipes was a great, and it's still a great idea, but there were limitations, you know, like first of all, Kyvee recipes, some of those recipes, they're outdated. So I tried building a few recipes. So I fought tidy and tried building new recipes by myself. And it wasn't easy task, you know, it's kind of so recipes, it's basically Python code. And there are a lot of historic stuff, you know, it's you should know about like a lot of debugging, I was really struggling trying to build new recipes and update existing recipes for Kairi.
- 20:34And also the biggest issue with Kairi's approach was you have to build all the Python runtime and all the modules like packages by yourself all the time.
- 20:48If you're a user, it's kind of pain. So you should enjoy SDK installed and all environment wearables in place you know like and I mean it could be a real struggle to build and it takes time sometimes like if you add NumPy pandas to your app as a dependencies it could take like half an hour to build all the packages and fingers crossed you know like whether it finishes okay you know or you get some weird pre-prepare yeah it wasn't nice it wasn't nice. I mean, it worked, this approach worked for simple things, you know, with the way your app requires fewer Python packages. But if it's not something trivial, it's either no recipe or outdated recipe, or you have to build your own recipe, etc, etc.
- 21:44And a recipe is basically saying how to build some particular library or Python itself for Android or for iOS or something, is that right?
- 21:53We can dig into that.
- 21:54Yeah.
- 21:54But it's kind of basically like settings.
- 21:57It's a bunch of settings for compiler for linker and how to move resulting files.
- 22:03You know, and basically that's it.
- 22:05Yeah.
- 22:05That doesn't sound that easy.
- 22:07Yeah, absolutely.
- 22:08Yeah.
- 22:08It's it's C, C++.
- 22:11Yeah.
- 22:11I can talk about this later, you know, it's.
- 22:14It's probably, probably people get enough of a, an idea from it.
- 22:18Is this, so I know that you are using or you publish serious Python.
- 22:23Is this sort of your answer to that?
- 22:25As we do open source and Kylie and other projects are open source, I thought maybe it's a good idea to contribute something to open source, right?
- 22:36We can do this as a part of our application templates, for example, and not dealing with this plugin, you know, but I thought maybe someone would be interested in using Python with your Clutter app.
- 22:52So C++ Python is a pretty low-level package that allows you to embed Python engine into your Clutter application.
- 23:02So, and I'm not sure if it's even popular, you know, but maybe someone can use it for some purposes.
- 23:10Do you do anything with Python build standalone?
- 23:14You know, uv has started making it really easy to install Python, all the different platforms of it by leveraging Python build standalone that was previously run by Greg now by Astral.
- 23:26Yes.
- 23:27Or do you do something else?
- 23:28Yeah.
- 23:28Like where you build, you build it for platforms.
- 23:31So you're talking about this GitHub project, building every version of Python for all platforms, right?
- 23:37Yeah.
- 23:38We use this repository for desktop as a, as a starting point and we don't want pre-built Python from that repo and we actually repackaged it.
- 23:48For mobile, now we use a different approach and I can talk about this.
- 23:53For web we use Pyodide.
- 23:55Yeah.
- 23:55Well, let's maybe talk for a little bit about the runtime side of things and we could talk about packaging after that.
- 24:03Flutter goes into all different places, more than most platforms.
- 24:07You can build desktop apps.
- 24:08You can build mobile apps.
- 24:09You can also build web apps, kind of a competitor to Angular or something like that.
- 24:15Right.
- 24:16And if you're going to have Python run times in these different locations, and that's kind of why I was asking about Python build standalone is, you know, there's all these variations of places that could be, which is quite tricky.
- 24:27Right.
- 24:27So the web version is WASM WebAssembly based, right?
- 24:32Web could be deployed in two like moments in two states, like client side and the server side.
- 24:40So if it's deployed as a server side app, obviously the Flutter part runs in the browser and Python runs on the server and it's standard Python with any module, you can use anything.
- 24:57And client part, client side, talks to server by web sockets.
- 25:04So all UI changes are streamed via web sockets to the client and all events go back to server side.
- 25:14So this is one mode, it's called server side.
- 25:16And another mode is client side or static web side.
- 25:21You can build, you can publish web app as a static website and put it on CloudFlare or GitHub pages or whatever you like.
- 25:33Yeah, you just put the WebAssembly files there and it just picks it up and goes, right?
- 25:36It's Flutter itself and Python, PyDyn, which is WebAssembly, which is Python and WebAssembly.
- 25:45So we don't compile Flutter part into WebAssembly yet because we have a lot of dependencies and not all of them support Wasm.
- 25:56But it's definitely on our roadmap and we'll have a branch trying to produce fastening builds.
- 26:04So it would be really nice because the size would be much smaller.
- 26:09The size of Flutter web would be much slower.
- 26:12It's probably right now it's 10 megabytes maybe.
- 26:16And it's going to be like two megabytes something.
- 26:20So it's going to be really nice when we do that.
- 26:23And with the right amount of caching, the right style of caching, it's not big of a deal, right?
- 26:27PyGuide is a pretty strong project.
- 26:30It has the biggest number of packages supported.
- 26:34So it's great.
- 26:36I mean, like it got really great support.
- 26:39I believe that the Python core devs are also working on getting Python itself to be a sort of officially built for WebAssembly.
- 26:50I know Brett Cannon's done a ton of work for this as well.
- 26:53Does that help you guys in any way?
- 26:55use built-in, this built-in Python support.
- 27:00So we migrated from Kylie to this approach.
- 27:03And it's thanks to the way guys, Russell and Malcolm.
- 27:09So Russell is iOS, Malcolm is Android.
- 27:12So they did a great, a really great job putting like this iOS and Android support into Python project itself.
- 27:21And now they, they like actually, they, they implemented the support for Python 3.13 and they ported to lower versions.
- 27:31Oh, nice.
- 27:32When I first, first saw the proposal, you know, for iOS, first of all, I really liked it.
- 27:40It's really great.
- 27:42I mean, like the way producing binary libraries, you know, like for, and packaging them, it's really good because we can use dynamic libraries versus static libraries entirely. Like entirely everything, like all these third-party modules you can file on your machine every time they produce static libraries. Basically like.a files for iOS. And finally, and they like the entire code base is like single executable at the end, you know, like everything like NumPy, like all this stuff is a single file.
- 28:20I mean, you cannot reuse some of those libraries, you know, like when you package them into iOS app, I really love the approach and I understood, you know, that it's probably the way going forward, you know, and you see it's kind of like it's getting like a standard now and it allows this approach allows you to have binary wheels that are prebuilt and put somewhere on not on PyPy.org yet.
- 28:50They don't support this model yet, but you can publish them on a custom feed, you know, and use and all users, all your users, they can download them from that location.
- 29:04Now that's it.
- 29:06Yeah, it's great.
- 29:08It's standard.
- 29:09And in the future, we can use pre-built wheels by like project maintainers, you know, like if NumPy, for example, decide releasing those wheels, we can, we can use them because we follow these standards, you know, like, so we use like standard runtime.
- 29:30Excellent.
- 29:31But NumPy folks, for example, as you said, they could use their expertise to get NumPy, this NumPy C code and Python code to build for WebAssembly and just put that in as automation and GitHub and everyone else in the world doesn't have to solve it over and over.
- 29:47Right?
- 29:48The Python 3.13 Python itself is, is pretty fresh.
- 29:52You know, it's many packages are still on, like don't support it.
- 29:58Right.
- 29:58So I believe like in at some point those projects will start doing their will start producing their own iOS and Android wheels and publishing them to PiPi once it's supported.
- 30:11So yeah, and of course, they can reuse our expertise.
- 30:16Yeah, you're making me dream, dream big, you know, like wheels for iOS and wheels for Android.
- 30:22Could you, could you imagine a day where it's as easy to just get libraries for the mobile platforms as it is for Mac or Linux or whatever?
- 30:31It's still not many people working in this area.
- 30:34And what I can tell you, it's like modern processors, modern CPUs in the Android and iOS, like Apple devices.
- 30:45They're pretty powerful, you know?
- 30:46And I remember there were a lot of like those times, like 2012, 2010, when Kylie and VWare started, there were a lot of issues trying to squeeze this desktop C code into a mobile processor.
- 31:04Now it's much easier. Most of those packages could be compiled as is without any tweaks, without any pictures, you know, so it's pretty, it's pretty nice.
- 31:15Maybe yeah, in the future we will have this as a standard thing, you know.
- 31:18Yeah.
- 31:19Last PyCon with the, maybe the Python before started, I think it was salt lake anyway, it doesn't really matter.
- 31:26Recently, Carol Willing at the PyCon US keynote talked about how mobile is such an important platform.
- 31:33And you know, there's people like you and Russell Keith-Magee and the B-Ware team working on it.
- 31:39But I think it feels a little chicken and an egg to me, you know, if it was a little easier, there would be a huge bunch of people that jump into it, but there's, it takes projects like Flet and the Beware one to just kind of unlock it.
- 31:53And then I think once it gets unlocked, people are going to realize and just go for it, you know, Kevin Python on the mobile devices is, is, is pretty awesome.
- 32:02You know, it's like for, for Android, for example, it's, it adds maybe like 8 megabytes of size to your app.
- 32:11So it's not so large.
- 32:12And it makes sense.
- 32:14Python is a great language.
- 32:15It's great for beginners, you know, for scientists.
- 32:20So it's really, I don't know, like addictive, you know, like to write apps for everything in Python.
- 32:28I've become like, I've been using Python for three years already, and I still love it, you know.
- 32:35Like I write most of my, like, even like sweets, you know, like in Python, like, so I'm looking back and all.
- 32:43Yeah.
- 32:43I've worked in a lot of programming languages, myself, static and dynamic ones.
- 32:48And yeah, it's Python.
- 32:49It's comfortable.
- 32:50It's nice.
- 32:51Yeah.
- 32:51All right.
- 32:52I want to talk about packaging and I know that's the area that you've been working on a lot as well.
- 32:57And as a segue, let's take a question from the audience.
- 33:00Alan out there asks, I'm someone taking a careful look at Flet.
- 33:04My question is what is the process of getting finished app reviewed by Apple or Google?
- 33:09I think, let me rephrase that into slightly different part because the reviewed by Apple or Google, there's like a voodoo doll and you stick it with a few pins and then you like rub it with an oil and then they, they approve your app, right?
- 33:23Like that seems to be the process.
- 33:25It's been so hard, but I think the thing is how do you get it built in a way that you can submit it to the app store?
- 33:32And then it's just down to, right?
- 33:33So what's the process?
- 33:35This is one of those rough questions, you know, it's, and you should have a list of rough questions.
- 33:41You're ready to answer.
- 33:43So right now you can build your APK for AAB for Android.
- 33:48You can sign it, but you have to upload the file manually right now into.
- 33:54I see.
- 33:54So you have to sideload it basically at the moment.
- 33:56YOLT command allows you to build the AAB file, which is basically APK for multiple platforms.
- 34:03sign it, and then you upload it by yourself through the web interface of Google Play.
- 34:09Oh, let me go back then. That's not side loading it. That's just not having it auto upload.
- 34:14Yeah.
- 34:14That's encouraging.
- 34:15So we have own Flag app in both Google Play and App Store. It's for testing apps on mobile devices. Basically, like the same flag client that connects to app through web sockets and the app itself is running on your machine.
- 34:32So yeah, and honestly, right now we publish it with Fastlane.
- 34:38So there is a CI job that publishes both iOS and Android versions with Fastlane.
- 34:46I'm not sure, maybe we will do the instructions how to use Fastlane because it's a great tool and it's pretty easy to synchronize certificates you know, for App Store and publish your app and make that information for app.
- 35:00So, yeah, but right now you can, you can build IP, you can build AAB, but you have to upload them manually.
- 35:08I think that's fine.
- 35:09Yeah.
- 35:09And then the review process starts.
- 35:11That's the voodoo doll part where you get the voodoo doll out and you hit it with the needles.
- 35:16People usually concerned about like, whether is it allowed to have Python or like the like stuff like that in your app and would it be approved by Apple, by Google?
- 35:29And I can tell you it works pretty well.
- 35:32We dogfood our own stuff.
- 35:34So we build Klet app using Klet.
- 35:37So the way it's packaged inside, it's getting approved.
- 35:43There are some issues.
- 35:43I can tell you there are some issues.
- 35:46For example, disabled, we used to disable x86 devices right away.
- 35:52And because they're like Google Play, usual machines, they show just like a black screen, you know, like, like the market share for those devices is pretty small right now.
- 36:05So we disabled that.
- 36:07So two plus is the review, but it works.
- 36:10It works.
- 36:11talk through the publishing workflow that you all have with the new CLI tools you got, but let's just dive into one more thing real quick.
- 36:20So when I have my Python code running, let's just say iOS, I have my Python code running on an iPhone.
- 36:27What is the runtime look like?
- 36:30Is that regular CPython?
- 36:33Can I add a standard package as a wheel?
- 36:37Like, could I use HTTPX?
- 36:39Like what is the story around the execution environment and the external packages and so on?
- 36:45It's CPython.
- 36:46As I said, right now we use, or this serious Python package, it uses Python.
- 36:52There is, by those scripts, which are part of Python 3.13.
- 36:58So like, theoretically, if you go there to Python repository and look into those, folders you will see instructions you can you can follow those instructions and build runtime like build CPython for both iOS and Android but yes this is it's not blossom it's CPython compiled into native iOS or Android code like platform for platform not like code assemble and binary packages yes you have to repackage, you have to build binary packages targeting those platforms as well. And for that purposes we use MobileForge project by DeWare.
- 37:41It's pretty nice, it's an awesome project, it's a brainchild of Malcolm and Russell.
- 37:48And yeah, in its turn it uses cross-env package, which is basically the way to simulate, like it allows you to create a virtual environment and Python thinks that it's being run on a mobile device, you know. So it's like basically MobileForge is like you do people install something and it feels like for Python it feels like it's being run this command on a mobile device and you it uses like if it's binary package and there is setup.py or pyproject.toml It uses mobile compilers, cross compilers to build.so file and produce a build.
- 38:33So if a pip install action requires a local build of something, it will use the mobile compilers with the target platform being like iPhone or whatever.
- 38:44The whole package like this cross-env, it tweaks Python into thinking it's kind of like running on a mobile device, you know, like it has these compilers, this archiver, this linker, you know, it's so nice. So like, and it's, it's pretty, it's pretty smart thing, you know, like in most cases, so you should do a recipe. But this time recipe is, is basically YAML file, it's like meta.yaml.
- 39:16And in most cases, if it's standard C, if it's simple package, you don't have to do anything.
- 39:24It works right away.
- 39:25You can build it for Android.
- 39:27You can build it for iOS.
- 39:29It takes literally minutes to produce a binary wheel for both platforms.
- 39:35I'll definitely link that in the show notes.
- 39:36All right, back to wherever I put it, the publishing side of things.
- 39:41So maybe we could talk through a little bit about the CLI and the process.
- 39:47Tell us, tell us how we go through this to get something built here.
- 39:49The first release, the first releases of web were using the like so-called web, like offering flat path command and using PyInstaller to produce executable.
- 40:01But it worked for desktop platforms as well only.
- 40:05And to produce the package, like the bundle for mobile platform, it's you need to do more. It's still possible as those guys are basically zip files inside, you know, you can build the AAB, you can build the APK, you can build the IPA by yourself or using Xcode tools. And it's like, it's the approach BWAM takes, for example. So the briefcase it builds like packages basically from scratch you know but for Flutter we use we require to use Flutter SDK so there is a new command let build which uses Flutter SDK and it's basically like a wrapper around the Flutter build command which allows you to build the app for desktop for web for mobile. So inside we take template, we take template and we create a new Flutter app and we build this Flutter app.
- 41:05Right. And just for people listening, the template looks something like here's a folder with a bunch of images and here's a main.py and a pyproject.toml, stuff that Python people would be familiar with.
- 41:15This is template for the app and template for Flutter app, it's something internal.
- 41:20You don't have to look into that.
- 41:22You know, it's like...
- 41:23It gets kind of complicated for the different platforms and linking them together and stuff.
- 41:27The problem with this, with Flutter is like the difference because we want to, we want to support extensions.
- 41:33We want to allow people using those nice extensions packages on pub.dev.
- 41:39So we cannot have the same process every time we, we should really run Flutter build to like, for example, include a media kit for video control or audio players package for audio control.
- 41:54It's not the same.
- 41:55It's always.
- 41:56So it should be built from dark to this code Flutter produces.
- 42:03That's a lot of what Flutter is.
- 42:04It's like orchestrating all the pieces to build into the right stuff to go into the mobile apps.
- 42:10Yeah, exactly.
- 42:11So we've got this pyproject.toml and you even have a create CLI command, like flit create my app or whatever.
- 42:19And it will go and get that all out there.
- 42:21Right.
- 42:22Recent stuff and still pretty rough.
- 42:25Yeah.
- 42:25And here you have flat build and then target platform and where a target platform is APK that is Android, AAB, IPA, which is iOS, web, macOS, windows, and Linux, that's a pretty impressive list of package destinations for building an executable.
- 42:41So if I build, let's suppose this.
- 42:43If I build a, let's say windows.
- 42:46I say target equals Windows, what files or file or executable or what do I get when I run that?
- 42:54Do I get just a.exe? Do I get a.exe with DLLs or a whole bunch of other stuff?
- 42:59Yeah, unfortunately it's not a single.exe, but it's.exe and a bunch of DLLs. Yes. It's, if you look inside the folder, you'll see like this executable, then Python itself, Python in runtime, which is a bunch of lead files, you know, and DLLs, Python files themselves, then your app coming as a zip file, also different kinds of DLLs from, from plugins, from extension packages, Flutter packages, like for video, for example, it's going to be like four more DLLs, something.
- 43:36So yeah, it's, it's, it's a bunch of things.
- 43:39Yeah.
- 43:39But, but it's something I could put into an installer or copy to a Windows And then you create a shortcut to the.exe and it, it looks like an app to the user.
- 43:49You can make self-extracting archive for MSI.
- 43:52Okay.
- 43:53And for macOS?
- 43:54For macOS, it's a bundle.
- 43:56Is that a.app bundle?
- 43:57Yeah.
- 43:58But it's a standard bundle that looks like a file, but it's a folder.
- 44:02Works like a charm, you know, like having the right structure.
- 44:05Again, the app inside is a part of the Flutter asset, which is like, it's called like car file.
- 44:13It's not like even the zip, it's car file and which has all the assets.
- 44:19Nice.
- 44:19It's a work in progress, you know, like to.
- 44:22Are you ready for the hard question now?
- 44:24Those are all awesome answers, but here's the one that has been driving me crazy.
- 44:28Is so many of these platforms by that, I mean, windows and Mac have anti malware, anti phishing protections, which is good, but that means if you build a dot app file and just try to run it.
- 44:45It'll say this is from an untrusted developer.
- 44:48We'll probably, you want to move it to the trash.
- 44:50You know what I mean?
- 44:50Like the lack of notarization or on windows, if it's not digitally signed with a trusted cert certificate, it gets treated with like a yellow warning.
- 45:00Is there a way to digitally sign these or notarize them through Apple?
- 45:06Yeah, I know flutter can do it.
- 45:07So maybe you could show up, maybe it shells down to the flutter side of how that works.
- 45:12But still, it looks pretty complicated, you know, like, even from my perspective, like, it looks pretty creepy.
- 45:19But I have this item on my desk right now to start from my class.
- 45:25Because there was a complaint from one user recently, like two days ago, and I still had this issue.
- 45:32So I'm gonna work on that, and I'm gonna provide, like, a definitive answer.
- 45:38It's not like I'm not going to say like it's do whatever you like.
- 45:42Like, no, I'm going to go through all this stuff because right now we honestly, we use it.
- 45:47We don't even use sandbox mode in produce.app file.
- 45:53You know, it's so we start from there and there was an issue with the loading Python binaries, like package binaries.
- 46:03I'm going to, I'm going to solve that problem as well.
- 46:06So yeah, definitely. It's our next step. Yeah. We, as you see, we're getting closer and closer to building real apps and we're getting more and more developers building real apps and they want to publish them. It's not just experimental, you know, anymore, like they want to publish them.
- 46:26And we are working on that right now, like publishing. And it's actually, it's our number one priority for the next year.
- 46:35I'll tell you, if you had that, that dialed, I mean, that means that that opens up desktop apps completely.
- 46:42Absolutely.
- 46:43Yeah.
- 46:43So we will, I will start from micro-ends because I have probably more, a little bit more experience with micro-ends right now.
- 46:52And then I want to continue with the Windows Store.
- 46:55I never published anything to Windows Store before.
- 46:58So it's going to be an interesting journey, you know, but yeah, Windows Store as well.
- 47:02Well, yeah, even if you just digitally signed it so that if you download it off someone else's website, it wouldn't go, Oh my gosh, this is an executable.
- 47:11That's untrusted runaway.
- 47:12You know, we actually sign our MSIs right now for, for other products.
- 47:18And it's kind of like conspiracy, you know, like, so you have to use a really expensive certificate to pass through what was like screen, Windows screen, something like, so it's not just even like code signing and not even easy code sign is something else.
- 47:38Yeah.
- 47:39Yeah.
- 47:39On MacOS it's gatekeeper and these sorts of things.
- 47:42Yeah.
- 47:42Yeah.
- 47:43I remember it's like $600 per year, something like that.
- 47:47At least if you want to pass this windows 11 screen.
- 47:52Yeah.
- 47:52Otherwise it's always a warning.
- 47:55Always.
- 47:55Where's the let's encrypt for desktop apps.
- 47:57Come on people, somebody help us out.
- 48:00Where's the cert bot for let's for desktop apps.
- 48:03But yeah, I, you know, like it's, it's there for a reason because people kept getting wrecked by ransomware and all sorts of stuff, but it does make building desktop apps challenging.
- 48:11Well, yeah, but we'll get there.
- 48:13No worries.
- 48:13I love it.
- 48:14All right.
- 48:14What else should we say about, about this here?
- 48:17I guess controls.
- 48:19I know there was a question.
- 48:20See a video.
- 48:21There was a question out in the audience also from Allen's is about camera controls.
- 48:26Is this a thing that you guys support yet?
- 48:29We started working on that, but it's not like it was kind of like testing the waters, you know, like it's kind of like at this moment we are trying to harmonize API, flat API and as I see it right now, we, we're going to split all controls into like visual controls and so-called services.
- 48:50So camera is going to be service because yeah, right now it's sometimes it's, it's messy, you know, like to use non-visual controls, you have to add them like to overlay or something.
- 49:04And like if you jump to a different page, it like audio could stop, you know, like, so we're going to re-implement that. And camera is true. Camera is the number one parameter right now. That's why there is a draft pull request and we're not closing it. So we keep it in mind The reason I even brought that up right now is because part of this packaging process, you have to state things like your permissions that you're requesting, like access to location.
- 49:39And you also have to include which optional controls you want to build like audio recorder or geolocation or maps and things like that.
- 49:48Right?
- 49:48This is something we're going to change by the next release as well.
- 49:53We will make this process more streamlined, easier to add new controls or services and include them into the build process.
- 50:03Well, even having them under a subsection of your pyproject.toml is pretty nice, actually.
- 50:10It looks standard, you know?
- 50:11Yeah.
- 50:11It looks like it belongs, which is really nice.
- 50:13Right.
- 50:14And obviously you've got icons and splash screens and all of those types of things that you have to include in order to build, especially mobile apps, but even icon for a dot app or dot exe.
- 50:25Yeah.
- 50:26I guess one more thing we got time for one more thing to call out here about this packaging side of things, or maybe, maybe two, but this one's pretty interesting is by default, flat will flat build.
- 50:36We'll just pile your Python app together and assume that it must be fine, but you have a --compile app option that will compile your Python files.
- 50:46Now people listening might think, well, but there's no Python compiler.
- 50:50There is a Python compiler.
- 50:51You just don't do anything with it.
- 50:52It's in the interpreter, right?
- 50:54So when Python loads your Python files, it converts it to a byte code and then interprets it.
- 51:00Right.
- 51:01But you can have it compile that to PYC files, which will detect problems.
- 51:05Right.
- 51:06That's kind of cool.
- 51:07Yeah.
- 51:07Yeah.
- 51:07Tell people about that a bit.
- 51:08One of the reasons we introduced those options is that if you always compile and there are some issues inside user code, the entire process fails, you know, Like even at least one single syntax error somewhere in your app leads to like a failed build process.
- 51:30And also you can disable compilation so it could be easy to debug your app.
- 51:38People asking like, is it like, can I see what's going on?
- 51:43Like if I am like downloaded your app and looked inside, like, can I see what's going on inside my app?
- 51:49Like can users see?
- 51:50Well, it's not the way to properly protect your app from someone looking at the logic.
- 52:00It's not 100% protection.
- 52:04So maybe you should use obfuscators.
- 52:06And we have some ideas to build obfuscating into Pipeline.
- 52:12I was thinking obfuscators were kind of like a separate thing.
- 52:16Imagine if it doesn't work.
- 52:18I mean, it's good if it works, like if you obfuscate it and it works, but Python is pretty complex thing because it's, it operates by text files, you know, like, so you can break some paths, you know, like module names, you know.
- 52:35Exactly.
- 52:36If it obfuscates the import statement or it's an import request, like that's not going to work anymore, you know, cause that's how Python works.
- 52:44It needs to see it.
- 52:44Yeah.
- 52:45I want to play with it.
- 52:46I want to play with it.
- 52:46If I compile my Python files, my PY files, does that omit them from the project and only include the PYC files or how does that work?
- 52:56We remove the PY.
- 52:58Yeah.
- 52:59That's already pretty, pretty good levels of obfuscation.
- 53:02There are disassemblers and decompilers for C code for, especially for.NET and Java, you can get those back to almost source level decompilation and sort of things.
- 53:12So yeah, that's, that's kind of close to at least close to, I would say it puts on par with.NET level of obvious cases.
- 53:18>> It's the star.
- 53:19>> Yeah.
- 53:19>> Yeah.
- 53:20All right.
- 53:20The last thing I guess we should talk about real quick is just permissions.
- 53:24So if you live in this mobile world, this is androidmanifest.xml or info.plist or.entitlements and all these things.
- 53:32And so you support these platform specific deals pretty much because Flutter supports them, right?
- 53:38>> It's not like pre-camped permissions.
- 53:41You can put anything you like.
- 53:42It's basically, it's whatever you put here into PyProject.toml or common line arguments, it goes directly to this build template.
- 53:55So it's, in fact, it's a big template, it's a cookie cutter template, and there are a bunch of for each statements, you know, like going through all these arrays.
- 54:06So whatever you put here, it goes to those entitlements, PLLs and manifest file.
- 54:13So it's pretty, it's pretty flexible.
- 54:15Yeah.
- 54:16But sure.
- 54:17We have like some predefined.
- 54:19When you say it's a cookie cutter thing, it's not just like a template.
- 54:24It literally uses the Python cookie cutter library, right?
- 54:27It's in a separate repository.
- 54:29So every flat build command downloads that template and provides the data.
- 54:36combined template and data and produces this Flutter app.
- 54:41And then it goes to Flutter build.
- 54:42>> It looks great.
- 54:43And it also looks like a lot of work.
- 54:45So congratulations on making it this far.
- 54:48>> Thank you.
- 54:50Yeah, it's still a lot of work.
- 54:51>> Yeah.
- 54:52Yeah.
- 54:52Yeah.
- 54:53Let's see.
- 54:53I wanted to just have you real quickly close out.
- 54:56I don't know where I stuck it somewhere in here, the roadmap for, for where you're going.
- 55:01So maybe tell us what's in the future.
- 55:03What's what's in the near term that people can count on and then we'll wrap up.
- 55:06Yeah, maybe this roadmap is already outdated, but yeah, first of all, we want to have this 1.0 because it's maybe it's a psychological thing, you know, it's like people, developers feel stability and all that.
- 55:23When there is 1.0, it says that the framework is ready for for SilverSaps.
- 55:29It's a commitment to sustainability.
- 55:31Like we think we're ready.
- 55:32It's commitment for sustainability and it's commitment for proper release schedule.
- 55:39So we'll keep this release after releasing it and we'll be providing patches to this 1.0, etc.
- 55:46So you can start doing real apps using 1.0.
- 55:50So it's 1.0 and we were doing a lot of work trying to harmonize API, trying to remove outdated stuff, trying to like have consistent naming conventions across different controls, you know, it's like property names, method names, remove different duplicates.
- 56:11So it's a lot of work and we're almost there.
- 56:16So definitely like another thing is improving developer experience, right?
- 56:23So improving developer experience, further improving developer experience, Like for example, we will be pre-installing all dependencies to make flood build command work really smooth on your computer.
- 56:37Like right now you have to install Flutter by itself, but we'll be installing correct version of Flutter on your behalf and Android is, yeah, Java, Java could be a pain, real pain.
- 56:50Like sending this Java home.
- 56:52If you're a people who have not been through Flutter projects, they don't They don't know all the little tools and the version mismatches.
- 57:01And I've got this version of Android Studio, but the Android SDK version wasn't checked correctly.
- 57:07And so now I can't, you know, like that, what you're saying is there's a lot of stuff that you could help out with and make that smoother, but it's challenging.
- 57:14Yeah. And still, it's still, you need Android Studio or Xcode or Visual Studio.
- 57:21Yeah. You can spend a lot of time configuring those things.
- 57:24You know what, maybe next year we're going to, we're going to work, start working on the service, you know, like I call it packaging and publishing service.
- 57:34So you could somehow link a GitHub branch, like a production branch or something.
- 57:39If you push that, you guys grab it and you'll build all the assets.
- 57:42Yeah.
- 57:42Nice.
- 57:43You can push your, just, you know, your code in this directory to this service and get artifact back, you know, like MSI file or ATP file.
- 57:55That's it.
- 57:56That'd be awesome.
- 57:56Actually.
- 57:57That's very cool.
- 57:57You don't need to deal with all these dependencies, like all this stuff, you know, it's you just do your part, your like Python code and that's it.
- 58:08And the rest will be done inside the, yeah, in the cloud.
- 58:12So that's the idea.
- 58:14That's the plan.
- 58:14Very promising.
- 58:15I love it.
- 58:16And I love all this work, all this progress you guys have made.
- 58:19So thanks for coming back on and sharing with everyone.
- 58:21Let's close it out.
- 58:23Final call to action.
- 58:23People are interested in Flet.
- 58:25What do you tell them?
- 58:26Go ahead.
- 58:27Download the latest version.
- 58:29Try doing your app and join our discord channel.
- 58:33Let us know what you think.
- 58:34Awesome.
- 58:35All right.
- 58:36Thanks a bunch.
- 58:36See you later.
- 58:37Yeah.
- 58:37Thank you guys.
- 58:39Bye.
- 58:40This has been another episode of talk Python to me.
- 58:43Thank you to our sponsors.
- 58:45Be sure to check out what they're offering.
- 58:46It really helps support the show.
- 58:48This episode is sponsored by Posit Connect from the makers of Shiny.
- 58:52Publish, share, and deploy all of your data projects that you're creating using Python.
- 58:57Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs.
- 59:04Posit Connect supports all of them.
- 59:06Try Posit Connect for free by going to talkpython.fm/posit, P-O-S-I-T.
- 59:12Want to level up your Python?
- 59:13We have one of the largest catalogs of Python video courses over at Talk Python.
- 59:17Our content ranges from true beginners to deeply advanced topics like memory and async.
- 59:22And best of all, there's not a subscription in sight.
- 59:25Check it out for yourself at training.talkpython.fm.
- 59:28Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 59:33We should be right at the top.
- 59:34You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the Direct RSS feed at /rss on talkpython.fm.
- 59:43We're live streaming most of our recordings these days.
- 59:46If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 59:55This is your host Michael Kennedy.
- 59:56Thanks so much for listening.
- 59:57I really appreciate it.
- 59:59Now get out there and write some Python code.