I don’t quite understand what you’re asking, but here’s an example of how I got it working:
Folder structure:
.
├── exampleapp
│ ├── __init__.py
│ ├── myscript.py
│ └── wrapped_cli_tool.py
└── setup.py
setup.py
import platform
import setuptools
import subprocess
setuptools.setup(
name='exampleapp',
version='1.0.0',
description='',
long_description='',
url='',
author='',
author_email='',
license='',
packages=['exampleapp'],
install_requires=['streamlit', 'click'],
zip_safe=False, # install source files not egg
entry_points={'console_scripts': [
'exampleapp = exampleapp.wrapped_cli_tool:main'
]},
)
wrapped_cli_tool.py
import click
import streamlit.cli
import os
@click.group()
def main():
pass
@main.command("streamlit")
def main_streamlit():
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, 'myscript.py')
args = []
streamlit.cli._main_run(filename, args)
if __name__ == "__main__":
main()
myscript.py
import streamlit as st
st.write('It worked!')
Instructions
- Call
python setup.py install
- Then try
exampleapp streamlit
! You should see “it worked” on your browser.