Reserved placeholder for pyw-core (umbrella namespace)
Project description
pyw-core ๐
Namespace seed & common utilities for the pythonWoods ecosystem.
Overview
pyw-core รจ il cuore dell'ecosistema pythonWoods, fornendo il namespace condiviso, utilities comuni e le basi architetturali per tutti i moduli. Anche se minimalista per design, รจ il fondamento che garantisce coerenza e interoperabilitร tra tutti i package.
Ecosystem Overview
| Package | Description | Status |
|---|---|---|
| pyw-core | Namespace & common utilities | 0.0.0 |
| pyw-logger | Structured logging (rich + structlog) | 0.0.0 |
| pyw-fs | Unified filesystem (local/S3/GCS) | 0.0.0 |
| pyw-secret | Secret backends (.env, Vault, SSM) | 0.0.0 |
| pyw-cli | Typer CLI scaffolding | 0.0.0 |
| pyw-config | Configuration utilities | 0.0.0 |
| pyw-vision | Vision utilities & helpers | 0.0.0 |
| pyw-motion | Motion detection & tracking | 0.0.0 |
| pyw-music21 | Music21 stubs & helpers | 0.0.0 |
| pyw-musicparser | Parse MIDI/Lilypond | 0.0.0 |
Bundle Packages
| Bundle | Description | Includes |
|---|---|---|
| pyw-devtools | Developer toolkit | logger, fs, cli, secret, config |
| pyw-music | Music processing | music21, musicparser |
| pyw-cv | Computer vision | vision, motion |
Philosophy
- Namespace package โ
import pyw.*per evitare conflitti e garantire coerenza - Small, composable modules โ scegli solo ciรฒ che ti serve, zero bloat
- Typed APIs โ Pydantic models e type hints per zero sorprese
- No heavy deps by default โ librerie "pesanti" (Torch, OpenCV) come extras opzionali
- Interoperability-first โ tutti i moduli condividono pattern e utilities comuni
Installation
pip install pyw-core
pyw-core รจ intenzionalmente minimalista: fornisce solo il namespace e utilities fondamentali condivise dall'ecosistema.
Core Features
๐๏ธ Base Classes
from pyw.core import BaseConfig, BaseModel
from pyw.core.types import PathLike, JsonDict
class MyConfig(BaseConfig):
"""Configurazione con validazione type-safe."""
name: str
debug: bool = False
paths: list[PathLike] = []
class DataModel(BaseModel):
"""Modello dati con serializzazione automatica."""
id: int
metadata: JsonDict = {}
๐ง Common Utilities
from pyw.core.utils import (
ensure_list, deep_merge, safe_import,
classproperty, deprecated
)
# List normalization
items = ensure_list("single_item") # โ ["single_item"]
items = ensure_list(["already", "list"]) # โ ["already", "list"]
# Deep dictionary merging
config = deep_merge(
{"db": {"host": "localhost", "port": 5432}},
{"db": {"port": 3306, "ssl": True}}
)
# โ {"db": {"host": "localhost", "port": 3306, "ssl": True}}
# Safe imports con fallback
requests = safe_import("requests", fallback_message="pip install requests")
# Class properties
class MyClass:
@classproperty
def version(cls):
return "1.0.0"
# Deprecation warnings
@deprecated("Use new_function() instead", version="2.0.0")
def old_function():
pass
๐ฆ Plugin Discovery
from pyw.core.plugins import discover_plugins, load_plugin
# Trova tutti i plugin pyw installati
plugins = discover_plugins("pyw.*")
# Carica plugin specifico
logger_plugin = load_plugin("pyw.logger")
๐ Type Utilities
from pyw.core.types import (
PathLike, JsonDict, OptionalStr,
Singleton, classproperty
)
from typing import Any
# Type aliases comuni
def process_file(path: PathLike) -> JsonDict:
"""Accetta str, Path, o file-like objects."""
pass
# Singleton pattern
class DatabaseConnection(Singleton):
def __init__(self):
self.connected = False
# Sempre la stessa istanza
db1 = DatabaseConnection()
db2 = DatabaseConnection()
assert db1 is db2
โก Performance Utilities
from pyw.core.performance import (
timer, cache_result, rate_limit,
memory_usage
)
import time
# Timing decorator
@timer
def slow_function():
time.sleep(1)
return "done"
result = slow_function() # Logs: "slow_function took 1.002s"
# Result caching
@cache_result(ttl=300) # Cache for 5 minutes
def expensive_computation(x: int) -> int:
return x ** 2
# Rate limiting
@rate_limit(calls=10, period=60) # Max 10 calls/minute
def api_call():
pass
# Memory monitoring
with memory_usage() as mem:
big_list = list(range(1000000))
print(f"Memory used: {mem.peak_mb:.1f} MB")
Integration Patterns
๐ Module Integration
# Pattern per moduli pyw
from pyw.core import BaseModule
class MyModule(BaseModule):
"""Template per nuovi moduli pyw."""
name = "my-module"
version = "1.0.0"
dependencies = ["pyw-core>=0.1.0"]
def __init__(self, config=None):
super().__init__()
self.config = config or self.default_config()
@classmethod
def default_config(cls):
return {"enabled": True}
๐งช Testing Support
from pyw.core.testing import (
temporary_directory, mock_environment,
assert_type_safe, benchmark
)
def test_my_function():
with temporary_directory() as tmpdir:
# Test con directory temporanea
pass
with mock_environment({"DEBUG": "true"}):
# Test con environment variables mock
pass
# Type safety testing
result = my_typed_function("input")
assert_type_safe(result, MyExpectedType)
# Performance benchmarking
with benchmark("my_operation") as b:
expensive_operation()
assert b.elapsed < 1.0 # Max 1 second
Bundle Installation
Per installare gruppi di moduli correlati:
# Developer toolkit completo
pip install pyw-devtools # logger + fs + cli + secret + config
# Music processing
pip install pyw-music # music21 + musicparser
# Computer vision
pip install pyw-cv # vision + motion
Advanced Usage
๐ Custom Extensions
from pyw.core.extensions import register_extension
@register_extension("mycompany.custom")
class CustomExtension:
"""Estensione personalizzata per pyw."""
def setup(self):
# Inizializzazione custom
pass
# Auto-discovered da pyw.core.plugins
๐ Ecosystem Stats
from pyw.core import ecosystem_info
# Info sull'ecosistema installato
info = ecosystem_info()
print(f"Installed pyw modules: {len(info.modules)}")
for module in info.modules:
print(f" {module.name} v{module.version}")
๐ฏ Quality Assurance
from pyw.core.qa import (
validate_module, check_compatibility,
run_ecosystem_tests
)
# Valida un modulo pyw
issues = validate_module("pyw.mymodule")
if issues:
for issue in issues:
print(f"โ ๏ธ {issue}")
# Check compatibilitร tra moduli
compat = check_compatibility(["pyw-logger==1.0", "pyw-fs==2.0"])
assert compat.compatible
Development Tools
๐๏ธ Module Scaffolding
# Crea nuovo modulo pyw
pyw-core scaffold my-module --type=utility
cd pyw-my-module/
# Struttura generata:
# pyw-my-module/
# โโโ pyw/
# โ โโโ my_module/
# โ โโโ __init__.py
# โ โโโ core.py
# โโโ tests/
# โโโ pyproject.toml
# โโโ README.md
๐ Quality Checks
# Linting ecosystem-wide
pyw-core lint --all-modules
# Type checking
pyw-core mypy --strict
# Run all tests
pyw-core test --coverage
# Check dependencies
pyw-core deps --check-conflicts
Roadmap
- ๐๏ธ Enhanced utilities: Async helpers, concurrency utilities
- ๐ฆ Plugin system: Hot-reloading, dependency injection
- ๐ง Dev experience: Better debugging, profiling integration
- ๐ Documentation: Auto-generated API docs, examples
- ๐ฏ Quality tools: Advanced linting, security scanning
- ๐ Ecosystem: Package discovery, compatibility matrix
- โก Performance: Caching strategies, optimization helpers
Contributing
pyw-core รจ il cuore dell'ecosistema - ogni contributo deve essere attentamente valutato:
- Fork & Clone:
git clone https://github.com/pythonWoods/pyw-core.git - Development setup:
poetry install && poetry shell - Quality checks:
ruff check . && mypy && pytest - Documentation: Aggiorna docs per ogni modifica API
- Compatibility: Assicurati che le modifiche non rompano altri moduli
- Pull Request: CI esegue test completi dell'ecosistema
Architecture Notes
pyw-core (namespace + utilities)
โโโ pyw/__init__.py # Namespace package
โโโ pyw/core/
โ โโโ __init__.py # Public API exports
โ โโโ base.py # BaseConfig, BaseModel
โ โโโ utils.py # Common utilities
โ โโโ types.py # Type aliases & helpers
โ โโโ plugins.py # Plugin discovery
โ โโโ performance.py # Performance tools
โ โโโ testing.py # Test utilities
โ โโโ exceptions.py # Common exceptions
โโโ tests/ # Comprehensive test suite
Felice coding nella foresta di pythonWoods! ๐ฒ๐พ
Links utili
Documentazione dev (work-in-progress) โ https://pythonwoods.dev/docs/pyw-core/latest/
Issue tracker โ https://github.com/pythonWoods/pyw-core/issues
Changelog โ https://github.com/pythonWoods/pyw-core/releases
ยฉ pythonWoods โ MIT License
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 pyw_core-0.0.0.post3.tar.gz.
File metadata
- Download URL: pyw_core-0.0.0.post3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf4893c1535c9e6c2fb5b0ed4314c5653b4583495d743f3629c211ff195e3d4c
|
|
| MD5 |
42d3f54149ce5af2d39a60007d94293f
|
|
| BLAKE2b-256 |
e35c382a8c385bd8658242bd7933c56ea78a69f5c74866c7e416fdff248e6d02
|
File details
Details for the file pyw_core-0.0.0.post3-py3-none-any.whl.
File metadata
- Download URL: pyw_core-0.0.0.post3-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c81e3a669f99b264b8c10293962712c190b850be99c70e9973e140618d53a1e0
|
|
| MD5 |
7d84b0725860e55d8851ed56eb074255
|
|
| BLAKE2b-256 |
d77d649f6061c722ae5366e10be5097615d001a7c6375b61c3d3ae56f483a44e
|