Metadata-Version: 2.4
Name: rz-sample
Version: 2.0.1
Summary: A python boilerplate for fastapi and streamlit projects.
License: MIT
License-File: LICENSE
License-File: LICENSE-PYTHON
Keywords: python,fastapi,streamlit,boilerplate
Author: recursivezero
Author-email: recursivezero@outlook.com
Requires-Python: >=3.10,<3.13
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Code Generators
Provides-Extra: mongo
Requires-Dist: bs4 (>=0.0.2,<0.0.3)
Requires-Dist: click (>=8.3.1,<9.0.0)
Requires-Dist: dotenv (>=0.9.9,<0.10.0)
Requires-Dist: fastapi (>=0.121.1,<0.122.0)
Requires-Dist: pydantic (>=2.12.5,<3.0.0)
Requires-Dist: pymongo (>=4.15.5,<5.0.0) ; extra == "mongo"
Requires-Dist: python-box (>=7.3.2,<8.0.0)
Requires-Dist: streamlit (>=1.49.0)
Requires-Dist: uvicorn (>=0.40.0,<0.41.0)
Project-URL: Documentation, https://github.com/recursivezero/sample-py#readme
Project-URL: Homepage, https://github.com/recursivezero/sample-py
Project-URL: Issues, https://github.com/recursivezero/sample-py/issues
Project-URL: Repository, https://github.com/recursivezero/sample-py.git
Description-Content-Type: text/markdown

# Sample-py

A streamlit, fast api boilerplate for python development

## Installation Guide

## Prerequisites

- Python ≥ 3.11
- Poetry ≥ 2.2.1
- Streamlit ≥ 1.49.1

## Getting Started

- [Unix/macOS Setup Guide][unix-setup]

- [Windows Setup Guide][windows-setup]

## Poetry Setup

```bash
curl -sSL https://install.python-poetry.org | python3 -
# OR
pip install poetry>=2.2.1
```

## Virtual Environment Configuration

```bash
poetry config virtualenvs.path /your/desired/path
```

Ensure below files are configured (create if not exist) properly to run the project;

- `.env.development`
- `.env.production`

## Install Dependencies

```bash
poetry lock --no-cache --regenerate
poetry install  --all-extras --with dev
```

Or manually

```bash
make install
```

## How to Run

## Configure ENVIRONMENT

setup `.env.development` and `.env.production` in project root

```bash
  # for local configuration(linux)
  export ENV=development
  # for production(linux)
  export ENV=production
```

## Run Streamlit App

```bash
make dev
#or with custom port
poetry run sample dev --port 8051

```

then open UI on : <http://localhost:8501>

to run on different port use `--port` option

```bash
poetry run sample dev --port 1234
```

## Run FastAPI Server

```bash
make api
#OR with custom port
poetry run sample api --port 5000
```

Access: <http://127.0.0.1:5000>

## 🧹 Linting & Code Quality

Pre-commit hooks are enabled. If commits fail, run:

```bash
make lint
```

or run individual

```bash
poetry run black .
poetry run flake8 .
poetry run mypy .
poetry run ruff check .
```

## Build & Packaging

## Build Package

```bash

poetry clean
poetry build
```

Artifacts in `dist/`

- sample-x.y.0-py3-none-any.whl
- sample-x.y.0.tar.gz

## Test Locally

```bash
python -m venv .venv-dist
source .venv-dist/bin/activate
# Windows
.venv-dist\Scripts\activate
```

### Install package

```bash
pip install dist/*.whl
pip install --upgrade dist/*.whl
# Install extras:
pip install sample
```

## CLI Shortcuts

`make dev` → Launch Streamlit UI

`make api` → Launch FastAPI

current version will be printed on start of above commands.

## Install GIT hooks

these hooks will

- Check for lint and audit for security before commit
- Append branch name in commit message
- Generate requirements.txt on checkout on new branch

```bash
# Install git hooks
make hooks
```

there is `.vscode/Python.code-profile` file; import this as a profile in vscode which include necessary extension for python development.

## Troubleshooting

sometimes there might be chances that virtual environment get corrupted then delete the old virtual environment and start afresh.

```sh
poetry env info
# this will provide virtual environment name
poetry env remove <environment-full-name>
```

## License

[MIT](https://github.com/recursivezero/sample-py/blob/main/LICENSE)

## References

[unix-setup]: https://github.com/recursivezero/python/wiki/setup-for-osx
[windows-setup]: https://github.com/recursivezero/python/wiki/setup-for-windows

- [Python Downloads](https://www.python.org/downloads)
- [Virtualenv Docs](https://docs.python.org/3/library/venv.html)
- [Poetry Docs](https://python-poetry.org/docs/)
- [MyPy Docs](https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports)
- [Useful Poetry Commands](https://github.com/recursivezero/python/wiki/POETRY_COMMANDS)

