Using streamlit in a compiled app

As I cannot run my streamlit app on a server due to company policy, I have to distribute my app using pyinstaller. For that, I am using pystray to create a tray icon. When the icon is clicked, I want the streamlit app to start. For obvious reasons, opening the streamlit app shouldn’t block the execution of the rest of the code and interactions with the tray icon. My first idea was to use subprocess.Popen

import subprocess
import sys
subprocess.Popen([sys.executable, "-m", "streamlit", "streamlit_app.py"])

However, once this code is compiled, sys.executable points towards the compiled app instead of the python interpreter, leading to a new instance of the app starting. My second idea was to run the streamlit app using:

import threading
from streamlit import config as _config
from streamlit.web.bootstrap import run
_config.set_option("server.headless", True)
def f():
    run('streamlit_app.py', args=[], flag_options=[], is_hello=False)
thread = threading.Thread(target=f)
thread.daemon = True
thread.start()

However, streamlit does not seem to be able to run inside a thread.
I am running out of ideas and would really appreciate help with this!