|
1 | | -# Streamlit Component Vue Vite Template |
| 1 | +# Streamlit Layoutr Component |
2 | 2 |
|
3 | | -A template for creating Streamlit Components. It uses Vue 3 to code the frontend and Vite to serve the files locally during development, as well as bundle and compile them for production. |
| 3 | +A Streamlit Component for Layoutr based on a template for creating Streamlit Components. It uses Vue 3 to code the frontend and Vite to serve the files locally during development, as well as bundle and compile them for production. |
4 | 4 |
|
5 | 5 | This repo contains templates and example code for creating [Streamlit](https://streamlit.io) Components. For complete information, please see the [Streamlit Components documentation](https://docs.streamlit.io/en/latest/streamlit_components.html)! |
6 | 6 |
|
7 | | -## Quickstart |
| 7 | +## Development |
8 | 8 |
|
9 | | -Ensure you have [Python 3.6+](https://www.python.org/downloads/), [Node.js](https://nodejs.org) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) installed. |
| 9 | +To develop the component, you need to have Node.js and npm installed. You can download them from [nodejs.org](https://nodejs.org/). |
10 | 10 |
|
11 | | -1. Clone this repository: |
| 11 | +1. Go to the `frontend` directory and initialize and run the component template frontend: |
12 | 12 | ``` bash |
13 | | -git clone git@github.com:gabrieltempass/streamlit-component-vue-vite-template.git |
14 | | -``` |
15 | | - |
16 | | -2. Go to the `frontend` directory and initialize and run the component template frontend: |
17 | | -``` bash |
18 | | -cd streamlit-component-vue-vite-template/streamlit_layoutr/frontend |
| 13 | +cd streamlit_layoutr/frontend |
19 | 14 | ``` |
20 | 15 | ``` bash |
21 | 16 | npm install |
22 | 17 | npm run dev |
23 | 18 | ``` |
24 | 19 |
|
25 | | -3. From a separate terminal, go to the repository root directory, create a new Python virtual environment, activate it and install Streamlit and the template as an editable package: |
26 | | -``` bash |
27 | | -cd streamlit-component-vue-vite-template |
28 | | -``` |
| 20 | +1. Set `_RELEASE = False` in `streamlit_layoutr/__init__.py`. This will pull the component live from `npm run dev` instead of the built version. |
| 21 | + |
| 22 | +1. From a separate terminal, go to the repository root directory, create a new Python virtual environment, activate it and install Streamlit and the template as an editable package: |
29 | 23 | ``` bash |
30 | 24 | python3 -m venv venv |
31 | 25 | . venv/bin/activate |
32 | 26 | pip install streamlit |
33 | 27 | pip install -e . |
34 | 28 | ``` |
35 | 29 |
|
36 | | -Still from the same separate terminal, run the example Streamlit app: |
| 30 | +1. Still from the same separate terminal, run the example Streamlit app: |
37 | 31 | ``` bash |
38 | 32 | streamlit run streamlit_layoutr/example.py |
39 | 33 | ``` |
40 | 34 |
|
41 | | -If all goes well, you should see something like this: |
| 35 | +If all goes well, you should see a sample app that lets you upload JSON and see it displayed in a graph. |
| 36 | + |
| 37 | +## Deployment to PyPI |
| 38 | + |
| 39 | +To deploy the component to PyPI, you need to build the frontend and package it with the Python code. |
42 | 40 |
|
43 | | - |
| 41 | +1. Update the version number in `setup.py`. |
44 | 42 |
|
45 | | -Modify the frontend code at `streamlit_layoutr/frontend/src/MyComponent.vue`. |
46 | | -Modify the Python code at `streamlit_layoutr/__init__.py`. |
| 43 | +2. Ensure `_RELEASE = True` in `streamlit_layoutr/__init__.py`. |
| 44 | + |
| 45 | +3. Build the frontend: |
| 46 | +``` bash |
| 47 | +cd streamlit_layoutr/frontend |
| 48 | +``` |
| 49 | +``` bash |
| 50 | +npm run build |
| 51 | +``` |
| 52 | +This will create a `dist` folder with the built files. |
| 53 | + |
| 54 | +4. Go to the root directory and build the package: |
| 55 | +``` bash |
| 56 | +python3 setup.py sdist bdist_wheel |
| 57 | +``` |
| 58 | + |
| 59 | +5. Upload the package to PyPI (requires access to the PyPI account): |
| 60 | +``` bash |
| 61 | +pip install twine |
| 62 | +twine upload dist/* |
| 63 | +``` |
47 | 64 |
|
48 | 65 | ## References |
49 | 66 |
|
|
0 commit comments