nyu-mlab / iot-inspector-client

IoT Inspector: capturing and analyzing your smart home network traffic
https://inspector.engineering.nyu.edu/
MIT License
417 stars 64 forks source link

Deployment script for macOS #224

Open crazyideas21 opened 10 months ago

crazyideas21 commented 10 months ago

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 commented 10 months ago

Non-ideas:

crazyideas21 commented 10 months ago

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.