🐍 PyReact - Framework Web Declarativo para Python
PyReact é um framework web declarativo inspirado no React, mas construído nativamente para Python. Permite criar interfaces de usuário reativas, com componentes, hooks e renderização eficiente.
📦 Instalação
Via pip (Recomendado)
pip install pyreact-framework
Via pip (GitHub)
pip install git+https://github.com/wanbnn/pyreact.git
Desenvolvimento Local
git clone https://github.com/wanbnn/pyreact.git
cd pyreact
pip install -e .
🚀 Início Rápido
Criar um Novo Projeto
# Criar projeto
pyreact-framework create meu-app
# Entrar no diretório
cd meu-app
# Iniciar servidor de desenvolvimento
pyreact-framework dev
Exemplo de Contador
from pyreact import h, render, use_state, Component
def Counter(props):
"""Componente de contador funcional"""
count, set_count = use_state(0)
return h('div', {'className': 'counter'},
h('h1', None, f'Contador: {count}'),
h('button', {'onClick': lambda: set_count(count + 1)}, '+'),
h('button', {'onClick': lambda: set_count(count - 1)}, '-')
)
# Renderizar
root = document.getElementById('root')
render(h(Counter, None), root)
✨ Funcionalidades
Componentes Funcionais
def Button(props):
"""Componente de botão reutilizável"""
return h('button', {
'className': 'btn',
'onClick': props.get('onClick')
}, props.get('children'))
Componentes de Classe
class Counter(Component):
"""Componente de contador com estado"""
def __init__(self, props):
super().__init__(props)
self.state = {'count': 0}
def render(self):
return h('div', None,
h('h1', None, f'Count: {self.state["count"]}'),
h('button', {
'onClick': lambda: self.set_state({'count': self.state['count'] + 1})
}, 'Increment')
)
Hooks
from pyreact import use_state, use_effect, use_ref
def MyComponent(props):
# Estado local
count, set_count = use_state(0)
# Efeito colateral
use_effect(lambda: print(f'Count: {count}'), [count])
# Referência
input_ref = use_ref(None)
return h('div', None, f'Count: {count}')
📖 Documentação
📚 Documentação Completa
A documentação completa está disponível no Read the Docs:
🔗 https://pyreact-framework.readthedocs.io/
Conteúdo da Documentação:
-
Getting Started
- Installation
- Quick Start
- Tutorial (Todo App)
-
Core Concepts
- Components
- Props
- State
- Events
- Lifecycle
-
Advanced
- Server-Side Rendering (SSR)
- Routing
- Styling
- Testing
-
API Reference
- Element API
- Component API
- Hooks API
- CLI API
CLI Commands
# Criar novo projeto
pyreact create <nome>
# Iniciar servidor de desenvolvimento
pyreact-framework dev [--port PORT]
# Gerar componente
pyreact generate component <nome>
# Gerar hook
pyreact generate hook <nome>
# Build para produção
pyreact build
API Principal
h(type, props, *children)
Cria um elemento virtual (VNode).
h('div', {'className': 'container'},
h('h1', None, 'Título'),
h('p', None, 'Parágrafo')
)
render(element, container)
Renderiza um elemento no container.
render(h(App, None), document.getElementById('root'))
create_root(container)
Cria uma raiz de renderização (API moderna).
root = create_root(document.getElementById('root'))
root.render(h(App, None))
🧪 Testes
Executar Testes
# Testes unitários
pytest tests/
# Testes E2E
pytest tests/e2e/ -v
# Com cobertura
pytest tests/ --cov=pyreact
Documentação de Testes
Ver docs/GUIA_EXECUCAO_E_TESTES.md para mais detalhes.
📁 Estrutura do Projeto
pyreact/
├── pyreact/ # Código fonte
│ ├── cli/ # Interface de linha de comando
│ ├── core/ # Núcleo do framework
│ ├── dom/ # Operações DOM
│ ├── server/ # Renderização servidor
│ └── utils/ # Utilitários
├── tests/ # Testes
│ ├── e2e/ # Testes end-to-end
│ └── unit/ # Testes unitários
├── examples/ # Exemplos
├── docs/ # Documentação e relatórios em PDF
├── pyproject.toml # Configuração do projeto
├── README.md # Este arquivo
├── INSTALL.md # Guia de instalação
├── PUBLISH.md # Guia de publicação
└── LICENSE # Licença MIT
🛠️ Desenvolvimento
Configurar Ambiente
# Clonar repositório
git clone https://github.com/wanbnn/pyreact.git
cd pyreact
# Criar ambiente virtual
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Instalar dependências
pip install -e .
# Instalar dependências de desenvolvimento
pip install -e ".[dev]"
pip install playwright
playwright install chromium
Executar em Desenvolvimento
# Instalar em modo editável
pip install -e .
# Executar testes
pytest tests/ -v
# Criar build
python -m build
📦 Publicação
Build
# Limpar builds anteriores
python -c "import shutil; from pathlib import Path; [shutil.rmtree(p, ignore_errors=True) for p in ['build', 'dist', 'pyreact.egg-info']]"
# Criar build
python -m build
Publicar no PyPI
# Instalar twine
pip install twine
# Verificar build
twine check dist/*
# Publicar no TestPyPI (teste)
twine upload --repository testpypi dist/*
# Publicar no PyPI (oficial)
twine upload dist/*
Ver PUBLISH.md para mais detalhes.
🤝 Contribuindo
Contribuições são bem-vindas! Por favor:
- Fork o projeto
- Crie uma branch para sua feature (
git checkout -b feature/AmazingFeature) - Commit suas mudanças (
git commit -m 'Add some AmazingFeature') - Push para a branch (
git push origin feature/AmazingFeature) - Abra um Pull Request
📝 Licença
Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE para detalhes.
📞 Contato
- GitHub Issues: https://github.com/wanbnn/pyreact/issues
- Documentação: https://pyreact.readthedocs.io/
- Email: contato@pyreact.dev
🙏 Agradecimentos
- Inspirado no React
- Construído com ❤️ pela comunidade Python
Feito com ❤️ pela comunidade Python
Metadata
Release files for pyreact-framework 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyreact_framework-1.0.5.tar.gz | 63.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyreact_framework-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 131.5 kB
Release files / pyreact_framework-1.0.5.tar.gz
| Download URL | pyreact_framework-1.0.5.tar.gz |
|---|---|
| Size | 63.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d01356ba378d08b0654d07a850e042bb2200c269bb105649b6ff7717bcb78b5f
|
|
BLAKE2b-256 checksum How to use checksums |
828b5159032ef05ad8a95a6206ae4c40af318187c9e17ef302420f5ee74ba2c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / pyreact_framework-1.0.5-py3-none-any.whl
| Download URL | pyreact_framework-1.0.5-py3-none-any.whl |
|---|---|
| Size | 67.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfa4f2766797033f22bb2a3726311acec0c1eb74bcf36bd3d1ebe9dba9bbc48b
|
|
BLAKE2b-256 checksum How to use checksums |
8726dfa1441e26be59782ea4685b7897f8b1be118a8cb5f9f9ecf29ab2cafbf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|