Biblioteca de operações matemáticas básicas em Python.
Project description
📟 FastAPI Calculator + Calculator-Lib
Projeto completo usando Python, FastAPI, Docker, GitHub Packages e GitHub Actions!
📚 O que esse projeto faz?
calculator-lib: biblioteca Python de operações matemáticas básicas.fastapi-calculator: serviço FastAPI que usa a calculator-lib para cálculos.- CI/CD Automático: testes → build → publicação no GitHub Packages → build da API → publicação da imagem Docker.
⚙️ Fluxo de CI/CD (GitHub Actions)
- Testa a biblioteca
calculator-lib - Publica a biblioteca no GitHub Packages
- Testa o serviço
fastapi-calculator - Builda e publica o container Docker no GitHub Container Registry (
ghcr.io)
✅ Cada etapa depende da anterior para garantir a qualidade!
📦 Instalação local
📚 1. Instalar a biblioteca calculator-lib
Se publicada no PyPI ou GitHub Packages:
pip install calculator-lib
Se localmente:
python -m pip install .
🚀 2. Rodar o serviço FastAPI
Instale as dependências:
python -m pip install -r requirements.txt
Suba a API:
uvicorn app.main:app --reload
Acesse: 👉 http://localhost:8000/docs
🐳 Rodar usando Docker e Docker Compose
📋 Buildar e rodar
make docker-build # Builda a imagem usando docker compose
make docker-up # Sobe o serviço
ou em modo detached:
make docker-up-detached
Para derrubar:
make docker-down
Para limpar tudo (imagens, volumes):
make docker-clean
🛠️ Makefile: Comandos úteis
| Comando | Ação |
|---|---|
make install |
Instalar dependências da API |
make install-lib |
Instalar calculator-lib |
make install-dev |
Instalar ferramentas de desenvolvimento |
make test-lib |
Testar a biblioteca |
make test-app |
Testar a API |
make build-lib |
Buildar lib tradicional (setup.py) |
make build-modern |
Buildar lib moderno (python -m build) |
make publish-lib |
Publicar lib (quando configurado) |
make docker-build |
Buildar imagem Docker via Compose |
make docker-up |
Subir serviço Docker |
make docker-up-detached |
Subir serviço em background |
make docker-down |
Derrubar containers |
make docker-clean |
Limpar containers, imagens, volumes |
📚 Publicação manual da calculator-lib
🛠️ Passo a passo
- Instalar ferramentas de build:
make install-dev
Ou diretamente:
python -m pip install build twine wheel
- Buildar a lib:
make build-modern
ou
python -m build
Isso vai gerar a pasta dist/ contendo .tar.gz e .whl.
- Publicar no GitHub Packages (ou PyPI)
Se configurado para GitHub Packages:
python -m twine upload dist/*
Lembre-se de configurar seu
.pypirce usar oGITHUB_TOKENouTWINE_USERNAME/TWINE_PASSWORD.
📂 Estrutura do Projeto
fastapi-calculator/
├── app/
│ ├── main.py
│ ├── models.py
├── calculator_lib/
│ ├── __init__.py
│ └── operations.py
├── tests/
│ └── test_main.py
├── tests_lib/
│ └── test_operations.py
├── docker-compose.yml
├── Dockerfile
├── Makefile
├── README.md
├── setup.py
├── pyproject.toml
└── .github/
└── workflows/
└── test-and-deploy.yml
testando a lib
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aprendendolib-0.1.3.tar.gz.
File metadata
- Download URL: aprendendolib-0.1.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7b4ee17ab62da5ab16481ed18e3d76f77d75abf2718ca5db4ff23f89ed5e268
|
|
| MD5 |
6046193d17389e4b305132e9d7c9a085
|
|
| BLAKE2b-256 |
68cd325971ef0f2603366928777b6e70421e77532fcc553e447415bdc6cdcc38
|
File details
Details for the file aprendendolib-0.1.3-py3-none-any.whl.
File metadata
- Download URL: aprendendolib-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
231971313aca1104910c9661533c019784dd9ab5109982f5b3f374b6d1f25573
|
|
| MD5 |
3464037ea563a413f37f5bcf0fde7699
|
|
| BLAKE2b-256 |
422fd4c6eec50880d5c3ce4a45794dd16daa16f28b0d9d01aee8175e83943520
|