Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment script for macOS #224

Open
crazyideas21 opened this issue Jan 25, 2024 · 2 comments
Open

Deployment script for macOS #224

crazyideas21 opened this issue Jan 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@crazyideas21
Copy link
Contributor

We currently deploy IoT Inspector on Windows by bundling the official binary of Python 3.8 and installing the required packages during the initial setup process. See this Windows shortcut file for details.

This process does not work for macOS, as there is no single standalone executable/binary for macOS.

I don't think (I might be wrong) we can use PyInstaller because of streamlit. As you go through the code, you'll see that the UI/UX for IoT Inspector is based on streamlit. To run Inspector, you'll have to put IoT Inspector's code as an argument to streamlit; see this line, i.e., effectively running python -m streamlit run Device_List.py. Although we can package streamlit with PyInstaller, PyInstaller can't deal with the dependencies for the IoT Inspector code (i.e., Device_List.py and others). I haven't found a way to launch IoT Inspector without first launching streamlit. In other words, it seems impossible to just do this: ./Device_List.py, where Device_List.py could somehow launch the streamlit server internally without needing to do python -m streamlit run Device_List.py.

If we can launch IoT Inspector with just ./Device_List.py or python Device_List.py, then the problem would be solved; we could simply process Device_List.py with PyInstaller, and PyInstaller will take care of the dependencies.

This is a critical issue. Until the above is solved, it's difficult to have a proper/easy macOS deployment.

@crazyideas21 crazyideas21 added the bug Something isn't working label Jan 25, 2024
@crazyideas21
Copy link
Contributor Author

crazyideas21 commented Jan 25, 2024

Non-ideas:

  • Technically, we could switch to Plotly Dash, as the Dash server could potentially be started from within IoT Inspector's code. I do not want to pursue this direction because (1) we would have to rewrite everything and (2) Plotly Dash, in my opinion, is more verbose and difficult to write, making it potentially difficult to attract new contributors. What I like about streamlit is its simplicity in the development process. We just have to figure out the deployment issue!
  • By default, macOS is not shipped with Python 3. We can't ask users to install Python 3 first, because macOS would have to download and install the developer tools first, which takes a long time.

@crazyideas21
Copy link
Contributor Author

crazyideas21 commented Jan 25, 2024

A few ideas: Use pyoxy as a standalone executable for Python on macOS. I haven't tested it. We will not worry about code-signing for now.

You can download a precompiled executable from https://github.com/indygreg/python-build-standalone/releases (basically from the PyOxidizer project).

I was inspired by how the datasette project distributes its macOS app: https://github.com/simonw/datasette-app/blob/main/download-python.sh

If this technique works, we could ship the pyoxy binary, have it masquerade as Python (per this post), and just run python -m streamlit run Device_List.py -- if this works.

Related idea: Or just package the Python interpreter with PyInstaller? Would this work?

Or this idea: See this article on how to use PyInstaller to package streamlit apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant