Skip to main content

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)

  1. Testa a biblioteca calculator-lib
  2. Publica a biblioteca no GitHub Packages
  3. Testa o serviço fastapi-calculator
  4. 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

  1. Instalar ferramentas de build:
make install-dev

Ou diretamente:

python -m pip install build twine wheel
  1. Buildar a lib:
make build-modern

ou

python -m build

Isso vai gerar a pasta dist/ contendo .tar.gz e .whl.

  1. Publicar no GitHub Packages (ou PyPI)

Se configurado para GitHub Packages:

python -m twine upload dist/*

Lembre-se de configurar seu .pypirc e usar o GITHUB_TOKEN ou TWINE_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calculadora_saraiva_lib-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calculadora_saraiva_lib-0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file calculadora_saraiva_lib-0.1.1.tar.gz.

File metadata

  • Download URL: calculadora_saraiva_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for calculadora_saraiva_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5ec0c69c4033a3e69dca0293e1bf9d659c66149d6807a0cac09e4bbd623eb71a
MD5 9ff93982ddd5b512ff0830ed5352c34e
BLAKE2b-256 5a0573813365d2d97ad9be3f97eb09c8a3d1c42a96e9e3a6c7b3430a60ea0c92

See more details on using hashes here.

File details

Details for the file calculadora_saraiva_lib-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for calculadora_saraiva_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98bf3a66f5e322b81ecf774f9b8e25ffd8077316b148ee2a5350116816a6d81b
MD5 b07b5a6fe81841f39e2392d7a23c97fd
BLAKE2b-256 93507f7070e2a4f3072970b088e2cb48d86256cdcfb9845d3d33893ba1c707a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page