Streamlit + Wasm + Electron = Desktop app!

Hi! This looks like a really amazing project @whitphx!

I just have a couple of questions as someone who’s completely new to electron + web development but is looking to make my streamlit app into a desktop app.

I’m slightly confused by the need for the entire streamlit app to be compiled into webassembly to work with electron. Is it just that it’s easier to port a frontend only web app to electron? From my understanding, electron apps can have ‘backend’ code too (I know this distinction doesn’t make sense for a desktop app). Is it just harder to get this to work with streamlit?

My issue is that my app has a number of fairly complex dependencies, and after some testing, I don’t think it’s going to be possible to get all the requirements to work with wasm.

That said, I do have another solution which seems to work great for my slightly unusual use case. I’ve written an app which is designed to run on the head node of a HPC (it does some database management and job scheduling). Since HPCs are always linux, I’ve packaged my app as a singularity container. This is an executable, which automatically runs the streamlit app, and runs its internal version of chromium in app mode when executed. Singularity containers share the host display, and users open the app through SSH X forwarding, so it works on basically any other machine.

I just want to know if this seems a silly solution to anyone, compared to using electron. I suppose the main thing is the issues here of portability away from linux and the overhead of a container don’t really apply for a HPC only app :stuck_out_tongue_winking_eye:

Thanks!

1 Like

Is it possible to share the streamlit desktop app with other users?

For Example - upon running all the steps mentioned in this forum, lets say i am able to create a dist folder under which there is an executable file that runs my streamlit app.

Now if I can share this folder with other users, is it going to run in the same way that used to work in my desktop?

1 Like

very cool, thanks for sharing this. I’m just starting to read up on WASM, so it is great to see examples

2 Likes

During establishing build files with yarn dump streamlit.app - requirements, I get the following error:
ValueError: Can’t find a pure Python 3 wheel for: ‘pyarrow>=7.0’, ‘tornado<7,>=6.0.3’, ‘watchdog>=2.1.5; platform_system != “Darwin”’

Is there any way to solve all dependencies and prepare a non-problematic wheels?

1 Like

@rbedford Sorry for a long delay of reply.

I first created “stlite”, a Wasm ver. of Streamlit, for technical interests and some benefits such as serverless execution or data privacy. Then I created the desktop app bundler as one of its applications.
So, for the purpose of packaging desktop apps, there are other options and you can use them as you actually did. Especially when your app doesn’t work on Wasm, stlite can’t be the option.

I just want to know if this seems a silly solution to anyone, compared to using electron.

So my answer to this is no. stlite is not always the best solution.

1 Like

Sorry for my late reply.

Yes.
@stlite/desktop just uses electron-builder to bundle the executables, so you can use its options to build.
To build packages for Mac, Windows, and Linux, you can use the following command.

yarn dist -mwl  # Same as "electron-builder -mwl"

See Multi Platform Build - electron-builder for the details.

Thank you @Sam_Keen !

@Hikmet I think your requirements.txt includes streamlit but it’s not allowed because the streamlit package is automatically installed by stlite specifying its special build.

The latest release of @stlite/desktop has been updated about this so that it ignores streamlit in requirements.txt.

1 Like

The latest release of @stlite/desktop includes the ways to persist files or sync files to the host OS.
Please check the README: