高性能、高质量的 Python 模块管理库,支持动态加载、生命周期管理、依赖解析和异步操作
Project description
Symphra Modules
高性能、高质量的 Python 模块管理库,支持动态加载、生命周期管理、依赖解析和异步操作。
✨ 核心特性
- 🚀 高性能设计 - 智能缓存、内存优化(
__slots__)、延迟加载 - 📦 灵活加载 - 支持目录、包、自动加载多种方式
- 🔄 生命周期管理 - 完整的状态机和钩子系统
- 🔗 依赖解析 - Kahn算法拓扑排序,循环检测
- 📡 事件驱动 - 发布订阅模式,通配符支持
- 🛡️ 类型安全 - mypy strict模式验证
- ⚡ 异步支持 - 原生支持同步/异步模块
📊 项目状态
- 测试: 117 passed (100%)
- 覆盖率: 79.78% (核心模块 80%+)
- 代码质量: ruff + mypy strict
- 文档: 中英双语 MkDocs
安装
pip install symphra-modules
或使用 uv:
uv add symphra-modules
🚀 快速开始
from symphra_modules import ModuleManager
from symphra_modules.abc import BaseModule, ModuleMetadata
# 1. 定义模块
class MyModule(BaseModule):
@property
def metadata(self) -> ModuleMetadata:
return ModuleMetadata(name="my_module", version="1.0.0")
def start(self) -> None:
print("模块已启动!")
# 2. 使用管理器
manager = ModuleManager()
manager.load_module("my_module", source="./modules")
manager.start_module("my_module")
📚 文档
在线文档
完整文档请访问: Symphra Modules Documentation
本地预览
# 启动文档服务器
uv run mkdocs serve
# 访问 http://localhost:8000
构建文档
# 构建静态文档
uv run mkdocs build
# 文档生成在 site/ 目录
🧪 测试
# 运行所有测试
uv run pytest
# 运行测试并生成覆盖率报告
uv run pytest --cov=symphra_modules --cov-report=html
# 查看覆盖率报告
open htmlcov/index.html
开发
环境准备
# 克隆项目
git clone https://github.com/getaix/symphra-modules.git
cd symphra-modules
# 安装依赖
uv sync
# 安装 pre-commit hooks
pre-commit install
运行测试
# 运行所有测试
uv run pytest
# 运行测试并显示覆盖率
uv run pytest --cov
# 运行特定测试
uv run pytest tests/unit/test_registry.py
代码质量检查
# 格式化代码
uv run ruff format .
# 代码检查
uv run ruff check .
# 类型检查
uv run mypy src
许可证
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
symphra_modules-0.1.0.tar.gz
(168.0 kB
view details)
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 symphra_modules-0.1.0.tar.gz.
File metadata
- Download URL: symphra_modules-0.1.0.tar.gz
- Upload date:
- Size: 168.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d894ec0731443950d3f5a99adf07df3fec2b553e8447cc2a9ed1e673ebe5df01
|
|
| MD5 |
5e976ba0d73231dbb05d5a51c3669326
|
|
| BLAKE2b-256 |
8ca2e188e6d6bdd159af83c78778ac7c39afd32b6c1c929379a06029b3d6d236
|
File details
Details for the file symphra_modules-0.1.0-py3-none-any.whl.
File metadata
- Download URL: symphra_modules-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e796e934d281328a45a7ef1bc1679163bb71946efa222bccb93c5a7cf2373255
|
|
| MD5 |
dcc7ce4a7b22178ea309b50e09e71676
|
|
| BLAKE2b-256 |
4eb74ba613cc0108456f474d6773b6673fa0d83f83aff81e5d037a2a5ef27f4f
|