That seems like it should work reasonably well. I made a simplified example of that script and it worked fine when I ran it with python
import time
import webbrowser
from pathlib import Path
from subprocess import check_output
path_to_main = Path(__file__).parent / "streamlit_app.py"
out = check_output(["streamlit", "run", str(path_to_main), "--server.port", "8501"])
print(out)
time.sleep(1)
webbrowser.open("http://localhost:8501/")
If you’re looking to make it into an executable, you should check out this post and see how others have accomplished this Streamlit Deployment as an Executable File (.exe) For Windows MacOS And Android