aury-boot 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aury_boot-0.0.2/.gitignore +47 -0
- aury_boot-0.0.2/PKG-INFO +265 -0
- aury_boot-0.0.2/README.md +194 -0
- aury_boot-0.0.2/aury/boot/_version.py +34 -0
- aury_boot-0.0.2/pyproject.toml +262 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
venv/
|
|
25
|
+
env/
|
|
26
|
+
ENV/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# Logs
|
|
35
|
+
*.log
|
|
36
|
+
log/
|
|
37
|
+
|
|
38
|
+
# Environment
|
|
39
|
+
.env
|
|
40
|
+
.env.local
|
|
41
|
+
|
|
42
|
+
# OS
|
|
43
|
+
.DS_Store
|
|
44
|
+
Thumbs.db
|
|
45
|
+
|
|
46
|
+
# Generated version files
|
|
47
|
+
*/_version.py
|
aury_boot-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aury-boot
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Aury Boot - 基于 FastAPI 生态的企业级 API 开发框架
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Requires-Dist: alembic>=1.17.2
|
|
7
|
+
Requires-Dist: babel>=2.17.0
|
|
8
|
+
Requires-Dist: faker>=38.2.0
|
|
9
|
+
Requires-Dist: fastapi>=0.122.0
|
|
10
|
+
Requires-Dist: greenlet>=3.2.4
|
|
11
|
+
Requires-Dist: httpx>=0.28.1
|
|
12
|
+
Requires-Dist: loguru>=0.7.3
|
|
13
|
+
Requires-Dist: pydantic-settings>=2.12.0
|
|
14
|
+
Requires-Dist: pydantic>=2.12.5
|
|
15
|
+
Requires-Dist: rich>=14.2.0
|
|
16
|
+
Requires-Dist: sqlalchemy>=2.0.44
|
|
17
|
+
Requires-Dist: tenacity>=9.1.2
|
|
18
|
+
Requires-Dist: typer>=0.20.0
|
|
19
|
+
Requires-Dist: uvicorn[standard]>=0.30.0
|
|
20
|
+
Provides-Extra: admin
|
|
21
|
+
Requires-Dist: itsdangerous>=2.2.0; extra == 'admin'
|
|
22
|
+
Requires-Dist: sqladmin>=0.16.0; extra == 'admin'
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: aiomysql>=0.3.2; extra == 'all'
|
|
25
|
+
Requires-Dist: aiosqlite>=0.21.0; extra == 'all'
|
|
26
|
+
Requires-Dist: amqp>=5.3.1; extra == 'all'
|
|
27
|
+
Requires-Dist: apscheduler>=3.11.1; extra == 'all'
|
|
28
|
+
Requires-Dist: asyncpg>=0.31.0; extra == 'all'
|
|
29
|
+
Requires-Dist: aury-sdk-storage[aws]>=0.0.1; extra == 'all'
|
|
30
|
+
Requires-Dist: dramatiq-kombu-broker>=0.2.2; extra == 'all'
|
|
31
|
+
Requires-Dist: dramatiq>=1.18.0; extra == 'all'
|
|
32
|
+
Requires-Dist: kombu>=5.6.1; extra == 'all'
|
|
33
|
+
Requires-Dist: redis>=7.1.0; extra == 'all'
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: mypy>=1.19.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest>=9.0.1; extra == 'dev'
|
|
39
|
+
Requires-Dist: ruff>=0.14.7; extra == 'dev'
|
|
40
|
+
Provides-Extra: docs
|
|
41
|
+
Requires-Dist: materialx>=1.39.0; extra == 'docs'
|
|
42
|
+
Requires-Dist: mkdocs-material>=9.7.0; extra == 'docs'
|
|
43
|
+
Requires-Dist: mkdocs>=1.6.0; extra == 'docs'
|
|
44
|
+
Provides-Extra: mysql
|
|
45
|
+
Requires-Dist: aiomysql>=0.3.2; extra == 'mysql'
|
|
46
|
+
Provides-Extra: postgres
|
|
47
|
+
Requires-Dist: asyncpg>=0.31.0; extra == 'postgres'
|
|
48
|
+
Provides-Extra: rabbitmq
|
|
49
|
+
Requires-Dist: amqp>=5.3.1; extra == 'rabbitmq'
|
|
50
|
+
Provides-Extra: recommended
|
|
51
|
+
Requires-Dist: apscheduler>=3.11.1; extra == 'recommended'
|
|
52
|
+
Requires-Dist: asyncpg>=0.31.0; extra == 'recommended'
|
|
53
|
+
Requires-Dist: aury-sdk-storage[aws]>=0.0.1; extra == 'recommended'
|
|
54
|
+
Requires-Dist: dramatiq-kombu-broker>=0.2.2; extra == 'recommended'
|
|
55
|
+
Requires-Dist: dramatiq>=1.18.0; extra == 'recommended'
|
|
56
|
+
Requires-Dist: kombu>=5.6.1; extra == 'recommended'
|
|
57
|
+
Requires-Dist: redis>=7.1.0; extra == 'recommended'
|
|
58
|
+
Provides-Extra: redis
|
|
59
|
+
Requires-Dist: redis>=7.1.0; extra == 'redis'
|
|
60
|
+
Provides-Extra: s3
|
|
61
|
+
Requires-Dist: aury-sdk-storage[aws]>=0.0.1; extra == 's3'
|
|
62
|
+
Provides-Extra: scheduler
|
|
63
|
+
Requires-Dist: apscheduler>=3.11.1; extra == 'scheduler'
|
|
64
|
+
Provides-Extra: sqlite
|
|
65
|
+
Requires-Dist: aiosqlite>=0.21.0; extra == 'sqlite'
|
|
66
|
+
Provides-Extra: tasks
|
|
67
|
+
Requires-Dist: dramatiq-kombu-broker>=0.2.2; extra == 'tasks'
|
|
68
|
+
Requires-Dist: dramatiq>=1.18.0; extra == 'tasks'
|
|
69
|
+
Requires-Dist: kombu>=5.6.1; extra == 'tasks'
|
|
70
|
+
Description-Content-Type: text/markdown
|
|
71
|
+
|
|
72
|
+
# Aury Boot
|
|
73
|
+
|
|
74
|
+
这是AUM项目的基于 FastAPI 生态的企业级 API 开发框架,提供所有微服务共用的基础设施组件。
|
|
75
|
+
|
|
76
|
+
## 功能模块
|
|
77
|
+
|
|
78
|
+
- **core**: 核心功能(数据库、缓存、任务调度等)
|
|
79
|
+
- **utils**: 工具函数(日志、安全、HTTP客户端等)
|
|
80
|
+
- **models**: 共享数据模型和响应模型
|
|
81
|
+
- **repositories**: 基础仓储模式
|
|
82
|
+
- **services**: 基础服务类
|
|
83
|
+
- **adapters**: 第三方服务适配器
|
|
84
|
+
- **rpc**: RPC通信框架
|
|
85
|
+
- **exceptions**: 错误处理系统
|
|
86
|
+
- **i18n**: 国际化支持
|
|
87
|
+
- **testing**: 测试框架
|
|
88
|
+
- **migrations**: 数据库迁移工具
|
|
89
|
+
|
|
90
|
+
## 主要功能
|
|
91
|
+
|
|
92
|
+
### 1. 国际化支持 (i18n)
|
|
93
|
+
|
|
94
|
+
提供完整的多语言支持,包括文本翻译、日期/数字本地化等:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from aury.boot.i18n import Translator, translate, set_locale
|
|
98
|
+
|
|
99
|
+
# 设置语言环境
|
|
100
|
+
set_locale("zh_CN")
|
|
101
|
+
|
|
102
|
+
# 使用翻译器
|
|
103
|
+
translator = Translator(locale="zh_CN")
|
|
104
|
+
message = translator.translate("user.created", name="张三")
|
|
105
|
+
|
|
106
|
+
# 使用简写函数
|
|
107
|
+
message = translate("user.created", name="张三")
|
|
108
|
+
|
|
109
|
+
# 装饰器方式
|
|
110
|
+
@_("user.title")
|
|
111
|
+
def get_user_title():
|
|
112
|
+
return "User Title" # 会被翻译
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 2. 测试框架
|
|
116
|
+
|
|
117
|
+
提供便捷的测试工具,包括测试基类、测试客户端、数据工厂等:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from aury.boot.testing import TestCase, TestClient, Factory
|
|
121
|
+
|
|
122
|
+
class UserServiceTest(TestCase):
|
|
123
|
+
"""测试基类,自动处理数据库事务回滚"""
|
|
124
|
+
|
|
125
|
+
async def setUp(self):
|
|
126
|
+
"""测试前准备"""
|
|
127
|
+
self.client = TestClient(app)
|
|
128
|
+
self.user_factory = Factory(User)
|
|
129
|
+
|
|
130
|
+
async def test_create_user(self):
|
|
131
|
+
"""测试创建用户"""
|
|
132
|
+
user = await self.user_factory.create(name="张三")
|
|
133
|
+
response = await self.client.post("/users", json={"name": "张三"})
|
|
134
|
+
assert response.status_code == 201
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 3. 数据库迁移工具
|
|
138
|
+
|
|
139
|
+
提供便捷的数据库迁移管理,类似 Django 的命令行接口:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from aury.boot.migrations import MigrationManager
|
|
143
|
+
|
|
144
|
+
# 使用 Python API
|
|
145
|
+
migration_manager = MigrationManager()
|
|
146
|
+
await migration_manager.make_migrations(message="add user table")
|
|
147
|
+
await migration_manager.migrate_up()
|
|
148
|
+
await migration_manager.migrate_down(version="previous")
|
|
149
|
+
status = await migration_manager.status()
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
命令行工具:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# 生成迁移文件
|
|
156
|
+
aury migrate make -m "add user table"
|
|
157
|
+
|
|
158
|
+
# 执行迁移
|
|
159
|
+
aury migrate up
|
|
160
|
+
|
|
161
|
+
# 回滚迁移
|
|
162
|
+
aury migrate down
|
|
163
|
+
|
|
164
|
+
# 查看状态
|
|
165
|
+
aury migrate status
|
|
166
|
+
|
|
167
|
+
# 显示迁移历史
|
|
168
|
+
aury migrate show
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 4. 代码生成器
|
|
172
|
+
|
|
173
|
+
快速生成标准的 CRUD 代码(模型、仓储、服务、API 路由):
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# 生成完整 CRUD(Model + Repository + Service + API)
|
|
177
|
+
aury generate crud user
|
|
178
|
+
|
|
179
|
+
# 单独生成各层代码
|
|
180
|
+
aury generate model user # SQLAlchemy 模型
|
|
181
|
+
aury generate repo user # Repository 仓储层
|
|
182
|
+
aury generate service user # Service 服务层
|
|
183
|
+
aury generate api user # API 路由
|
|
184
|
+
|
|
185
|
+
# 交互式生成(推荐):逐步选择字段、类型、验证规则
|
|
186
|
+
aury generate crud user -i
|
|
187
|
+
aury generate model user -i
|
|
188
|
+
|
|
189
|
+
# 指定字段(非交互式)
|
|
190
|
+
aury generate model user --fields "name:str,email:str,age:int"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**交互式模式 (`-i`)** 会引导你:
|
|
194
|
+
- 添加字段名称和类型
|
|
195
|
+
- 设置字段约束(唯一、可空、默认值等)
|
|
196
|
+
- 配置关系字段(外键、多对多等)
|
|
197
|
+
- 自动插入 API 路由到 `api/__init__.py`
|
|
198
|
+
|
|
199
|
+
生成的代码遵循项目架构模式,开箱即用。
|
|
200
|
+
|
|
201
|
+
## 使用方式
|
|
202
|
+
|
|
203
|
+
在AUM工作区内的其他包中,可以直接导入:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from aury.boot.infrastructure.database import DatabaseManager
|
|
207
|
+
from aury.boot.infrastructure.logging import logger
|
|
208
|
+
from aury.boot.core import BaseModel, BaseRepository, BaseService
|
|
209
|
+
from aury.boot.interfaces import BaseRequest, BaseResponse
|
|
210
|
+
from aury.boot.application.rpc import RPCClient
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## 开发指南
|
|
214
|
+
|
|
215
|
+
修改此包后,所有依赖它的服务都会自动使用最新版本,无需重新安装。
|
|
216
|
+
|
|
217
|
+
## 安装
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# 推荐(PostgreSQL + Redis + 任务队列 + 调度器)
|
|
221
|
+
uv add "aury-boot[recommended]"
|
|
222
|
+
|
|
223
|
+
# 或按需组合
|
|
224
|
+
uv add "aury-boot[postgres,redis]"
|
|
225
|
+
|
|
226
|
+
# 全部依赖
|
|
227
|
+
uv add "aury-boot[all]"
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 可选依赖
|
|
231
|
+
|
|
232
|
+
| 名称 | 说明 |
|
|
233
|
+
|------|------|
|
|
234
|
+
| `postgres` | PostgreSQL 数据库 |
|
|
235
|
+
| `mysql` | MySQL 数据库 |
|
|
236
|
+
| `sqlite` | SQLite 数据库 |
|
|
237
|
+
| `redis` | Redis 缓存 |
|
|
238
|
+
| `s3` | S3 对象存储 |
|
|
239
|
+
| `tasks` | 任务队列 |
|
|
240
|
+
| `rabbitmq` | RabbitMQ 支持 |
|
|
241
|
+
| `scheduler` | 定时调度 |
|
|
242
|
+
| `recommended` | 推荐组合 |
|
|
243
|
+
| `all` | 全部依赖 |
|
|
244
|
+
|
|
245
|
+
## 开发环境设置
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# 克隆仓库
|
|
249
|
+
git clone https://github.com/AUMNeo/aury-boot.git
|
|
250
|
+
cd aury-boot
|
|
251
|
+
|
|
252
|
+
# 安装依赖
|
|
253
|
+
uv sync --group dev
|
|
254
|
+
|
|
255
|
+
# 运行测试
|
|
256
|
+
pytest
|
|
257
|
+
|
|
258
|
+
# 代码检查
|
|
259
|
+
ruff check .
|
|
260
|
+
mypy aury/
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Aury Boot
|
|
2
|
+
|
|
3
|
+
这是AUM项目的基于 FastAPI 生态的企业级 API 开发框架,提供所有微服务共用的基础设施组件。
|
|
4
|
+
|
|
5
|
+
## 功能模块
|
|
6
|
+
|
|
7
|
+
- **core**: 核心功能(数据库、缓存、任务调度等)
|
|
8
|
+
- **utils**: 工具函数(日志、安全、HTTP客户端等)
|
|
9
|
+
- **models**: 共享数据模型和响应模型
|
|
10
|
+
- **repositories**: 基础仓储模式
|
|
11
|
+
- **services**: 基础服务类
|
|
12
|
+
- **adapters**: 第三方服务适配器
|
|
13
|
+
- **rpc**: RPC通信框架
|
|
14
|
+
- **exceptions**: 错误处理系统
|
|
15
|
+
- **i18n**: 国际化支持
|
|
16
|
+
- **testing**: 测试框架
|
|
17
|
+
- **migrations**: 数据库迁移工具
|
|
18
|
+
|
|
19
|
+
## 主要功能
|
|
20
|
+
|
|
21
|
+
### 1. 国际化支持 (i18n)
|
|
22
|
+
|
|
23
|
+
提供完整的多语言支持,包括文本翻译、日期/数字本地化等:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from aury.boot.i18n import Translator, translate, set_locale
|
|
27
|
+
|
|
28
|
+
# 设置语言环境
|
|
29
|
+
set_locale("zh_CN")
|
|
30
|
+
|
|
31
|
+
# 使用翻译器
|
|
32
|
+
translator = Translator(locale="zh_CN")
|
|
33
|
+
message = translator.translate("user.created", name="张三")
|
|
34
|
+
|
|
35
|
+
# 使用简写函数
|
|
36
|
+
message = translate("user.created", name="张三")
|
|
37
|
+
|
|
38
|
+
# 装饰器方式
|
|
39
|
+
@_("user.title")
|
|
40
|
+
def get_user_title():
|
|
41
|
+
return "User Title" # 会被翻译
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. 测试框架
|
|
45
|
+
|
|
46
|
+
提供便捷的测试工具,包括测试基类、测试客户端、数据工厂等:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from aury.boot.testing import TestCase, TestClient, Factory
|
|
50
|
+
|
|
51
|
+
class UserServiceTest(TestCase):
|
|
52
|
+
"""测试基类,自动处理数据库事务回滚"""
|
|
53
|
+
|
|
54
|
+
async def setUp(self):
|
|
55
|
+
"""测试前准备"""
|
|
56
|
+
self.client = TestClient(app)
|
|
57
|
+
self.user_factory = Factory(User)
|
|
58
|
+
|
|
59
|
+
async def test_create_user(self):
|
|
60
|
+
"""测试创建用户"""
|
|
61
|
+
user = await self.user_factory.create(name="张三")
|
|
62
|
+
response = await self.client.post("/users", json={"name": "张三"})
|
|
63
|
+
assert response.status_code == 201
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. 数据库迁移工具
|
|
67
|
+
|
|
68
|
+
提供便捷的数据库迁移管理,类似 Django 的命令行接口:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from aury.boot.migrations import MigrationManager
|
|
72
|
+
|
|
73
|
+
# 使用 Python API
|
|
74
|
+
migration_manager = MigrationManager()
|
|
75
|
+
await migration_manager.make_migrations(message="add user table")
|
|
76
|
+
await migration_manager.migrate_up()
|
|
77
|
+
await migration_manager.migrate_down(version="previous")
|
|
78
|
+
status = await migration_manager.status()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
命令行工具:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# 生成迁移文件
|
|
85
|
+
aury migrate make -m "add user table"
|
|
86
|
+
|
|
87
|
+
# 执行迁移
|
|
88
|
+
aury migrate up
|
|
89
|
+
|
|
90
|
+
# 回滚迁移
|
|
91
|
+
aury migrate down
|
|
92
|
+
|
|
93
|
+
# 查看状态
|
|
94
|
+
aury migrate status
|
|
95
|
+
|
|
96
|
+
# 显示迁移历史
|
|
97
|
+
aury migrate show
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. 代码生成器
|
|
101
|
+
|
|
102
|
+
快速生成标准的 CRUD 代码(模型、仓储、服务、API 路由):
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# 生成完整 CRUD(Model + Repository + Service + API)
|
|
106
|
+
aury generate crud user
|
|
107
|
+
|
|
108
|
+
# 单独生成各层代码
|
|
109
|
+
aury generate model user # SQLAlchemy 模型
|
|
110
|
+
aury generate repo user # Repository 仓储层
|
|
111
|
+
aury generate service user # Service 服务层
|
|
112
|
+
aury generate api user # API 路由
|
|
113
|
+
|
|
114
|
+
# 交互式生成(推荐):逐步选择字段、类型、验证规则
|
|
115
|
+
aury generate crud user -i
|
|
116
|
+
aury generate model user -i
|
|
117
|
+
|
|
118
|
+
# 指定字段(非交互式)
|
|
119
|
+
aury generate model user --fields "name:str,email:str,age:int"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**交互式模式 (`-i`)** 会引导你:
|
|
123
|
+
- 添加字段名称和类型
|
|
124
|
+
- 设置字段约束(唯一、可空、默认值等)
|
|
125
|
+
- 配置关系字段(外键、多对多等)
|
|
126
|
+
- 自动插入 API 路由到 `api/__init__.py`
|
|
127
|
+
|
|
128
|
+
生成的代码遵循项目架构模式,开箱即用。
|
|
129
|
+
|
|
130
|
+
## 使用方式
|
|
131
|
+
|
|
132
|
+
在AUM工作区内的其他包中,可以直接导入:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from aury.boot.infrastructure.database import DatabaseManager
|
|
136
|
+
from aury.boot.infrastructure.logging import logger
|
|
137
|
+
from aury.boot.core import BaseModel, BaseRepository, BaseService
|
|
138
|
+
from aury.boot.interfaces import BaseRequest, BaseResponse
|
|
139
|
+
from aury.boot.application.rpc import RPCClient
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 开发指南
|
|
143
|
+
|
|
144
|
+
修改此包后,所有依赖它的服务都会自动使用最新版本,无需重新安装。
|
|
145
|
+
|
|
146
|
+
## 安装
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# 推荐(PostgreSQL + Redis + 任务队列 + 调度器)
|
|
150
|
+
uv add "aury-boot[recommended]"
|
|
151
|
+
|
|
152
|
+
# 或按需组合
|
|
153
|
+
uv add "aury-boot[postgres,redis]"
|
|
154
|
+
|
|
155
|
+
# 全部依赖
|
|
156
|
+
uv add "aury-boot[all]"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 可选依赖
|
|
160
|
+
|
|
161
|
+
| 名称 | 说明 |
|
|
162
|
+
|------|------|
|
|
163
|
+
| `postgres` | PostgreSQL 数据库 |
|
|
164
|
+
| `mysql` | MySQL 数据库 |
|
|
165
|
+
| `sqlite` | SQLite 数据库 |
|
|
166
|
+
| `redis` | Redis 缓存 |
|
|
167
|
+
| `s3` | S3 对象存储 |
|
|
168
|
+
| `tasks` | 任务队列 |
|
|
169
|
+
| `rabbitmq` | RabbitMQ 支持 |
|
|
170
|
+
| `scheduler` | 定时调度 |
|
|
171
|
+
| `recommended` | 推荐组合 |
|
|
172
|
+
| `all` | 全部依赖 |
|
|
173
|
+
|
|
174
|
+
## 开发环境设置
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# 克隆仓库
|
|
178
|
+
git clone https://github.com/AUMNeo/aury-boot.git
|
|
179
|
+
cd aury-boot
|
|
180
|
+
|
|
181
|
+
# 安装依赖
|
|
182
|
+
uv sync --group dev
|
|
183
|
+
|
|
184
|
+
# 运行测试
|
|
185
|
+
pytest
|
|
186
|
+
|
|
187
|
+
# 代码检查
|
|
188
|
+
ruff check .
|
|
189
|
+
mypy aury/
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '0.0.2'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 0, 2)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "aury-boot"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Aury Boot - 基于 FastAPI 生态的企业级 API 开发框架"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"fastapi>=0.122.0",
|
|
9
|
+
"sqlalchemy>=2.0.44",
|
|
10
|
+
"alembic>=1.17.2",
|
|
11
|
+
"greenlet>=3.2.4",
|
|
12
|
+
"pydantic>=2.12.5",
|
|
13
|
+
"pydantic-settings>=2.12.0",
|
|
14
|
+
"httpx>=0.28.1",
|
|
15
|
+
"loguru>=0.7.3",
|
|
16
|
+
"tenacity>=9.1.2",
|
|
17
|
+
"typer>=0.20.0",
|
|
18
|
+
"uvicorn[standard]>=0.30.0",
|
|
19
|
+
"rich>=14.2.0",
|
|
20
|
+
"babel>=2.17.0",
|
|
21
|
+
"faker>=38.2.0",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
# ============ 开发工具 ============
|
|
26
|
+
dev = [
|
|
27
|
+
"pytest>=9.0.1",
|
|
28
|
+
"pytest-asyncio>=1.3.0",
|
|
29
|
+
"pytest-cov>=7.0.0",
|
|
30
|
+
"ruff>=0.14.7",
|
|
31
|
+
"mypy>=1.19.0",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
# ============ 文档生成 ============
|
|
35
|
+
docs = [
|
|
36
|
+
"mkdocs>=1.6.0",
|
|
37
|
+
"mkdocs-material>=9.7.0",
|
|
38
|
+
"materialx>=1.39.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
# ============ 数据库驱动 ============
|
|
42
|
+
postgres = ["asyncpg>=0.31.0"]
|
|
43
|
+
mysql = ["aiomysql>=0.3.2"]
|
|
44
|
+
sqlite = ["aiosqlite>=0.21.0"]
|
|
45
|
+
|
|
46
|
+
# ============ 缓存 ============
|
|
47
|
+
redis = ["redis>=7.1.0"]
|
|
48
|
+
|
|
49
|
+
# ============ 对象存储 ============
|
|
50
|
+
s3 = ["aury-sdk-storage[aws]>=0.0.1"]
|
|
51
|
+
|
|
52
|
+
# ============ 任务队列 ============
|
|
53
|
+
tasks = [
|
|
54
|
+
"dramatiq>=1.18.0",
|
|
55
|
+
"kombu>=5.6.1",
|
|
56
|
+
"dramatiq-kombu-broker>=0.2.2",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
# ============ 消息队列后端 ============
|
|
60
|
+
rabbitmq = ["amqp>=5.3.1"] # 需要配合 tasks 使用
|
|
61
|
+
|
|
62
|
+
# ============ 定时调度 ============
|
|
63
|
+
scheduler = ["apscheduler>=3.11.1"]
|
|
64
|
+
|
|
65
|
+
# ============ 管理后台(SQLAdmin) ============
|
|
66
|
+
admin = [
|
|
67
|
+
"sqladmin>=0.16.0",
|
|
68
|
+
"itsdangerous>=2.2.0",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
# ============ 组合包 ============
|
|
72
|
+
# 推荐:PostgreSQL + Redis + 任务队列 + 调度器
|
|
73
|
+
recommended = [
|
|
74
|
+
"asyncpg>=0.31.0",
|
|
75
|
+
"redis>=7.1.0",
|
|
76
|
+
"dramatiq>=1.18.0",
|
|
77
|
+
"kombu>=5.6.1",
|
|
78
|
+
"dramatiq-kombu-broker>=0.2.2",
|
|
79
|
+
"apscheduler>=3.11.1",
|
|
80
|
+
"aury-sdk-storage[aws]>=0.0.1",
|
|
81
|
+
]
|
|
82
|
+
# 完整:所有可选依赖
|
|
83
|
+
all = [
|
|
84
|
+
"asyncpg>=0.31.0",
|
|
85
|
+
"aiomysql>=0.3.2",
|
|
86
|
+
"aiosqlite>=0.21.0",
|
|
87
|
+
"redis>=7.1.0",
|
|
88
|
+
"aury-sdk-storage[aws]>=0.0.1",
|
|
89
|
+
"dramatiq>=1.18.0",
|
|
90
|
+
"kombu>=5.6.1",
|
|
91
|
+
"dramatiq-kombu-broker>=0.2.2",
|
|
92
|
+
"amqp>=5.3.1",
|
|
93
|
+
"apscheduler>=3.11.1",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[project.scripts]
|
|
97
|
+
aury = "aury.boot.commands:main"
|
|
98
|
+
|
|
99
|
+
[tool.uv]
|
|
100
|
+
index-url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
101
|
+
|
|
102
|
+
[tool.ruff]
|
|
103
|
+
target-version = "py313"
|
|
104
|
+
line-length = 120
|
|
105
|
+
indent-width = 4
|
|
106
|
+
exclude = [
|
|
107
|
+
".git",
|
|
108
|
+
".venv",
|
|
109
|
+
"__pycache__",
|
|
110
|
+
"*.pyc",
|
|
111
|
+
".mypy_cache",
|
|
112
|
+
".pytest_cache",
|
|
113
|
+
".ruff_cache",
|
|
114
|
+
"build",
|
|
115
|
+
"dist",
|
|
116
|
+
"*.egg-info",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[tool.ruff.lint]
|
|
120
|
+
select = [
|
|
121
|
+
"E", # pycodestyle errors
|
|
122
|
+
"W", # pycodestyle warnings
|
|
123
|
+
"F", # Pyflakes
|
|
124
|
+
"I", # isort
|
|
125
|
+
"N", # pep8-naming
|
|
126
|
+
"UP", # pyupgrade (Python 3.13 语法升级)
|
|
127
|
+
"B", # flake8-bugbear
|
|
128
|
+
"C4", # flake8-comprehensions
|
|
129
|
+
"SIM", # flake8-simplify
|
|
130
|
+
"T20", # flake8-print
|
|
131
|
+
"PYI", # flake8-pyi
|
|
132
|
+
"PT", # flake8-pytest-style
|
|
133
|
+
"RUF", # Ruff-specific rules
|
|
134
|
+
]
|
|
135
|
+
ignore = [
|
|
136
|
+
"E501", # 行长度(由 line-length 配置)
|
|
137
|
+
"E402", # 模块级别导入(允许在文档字符串后导入)
|
|
138
|
+
"F401", # 未使用的导入(在 __init__.py 中允许)
|
|
139
|
+
"F841", # 未使用的变量(某些情况下需要)
|
|
140
|
+
"B008", # 函数调用中的默认参数(某些装饰器需要)
|
|
141
|
+
"B006", # 可变默认参数(某些情况下需要)
|
|
142
|
+
"T201", # print 语句(测试和脚本中允许)
|
|
143
|
+
"SIM108", # 使用三元表达式(某些情况下可读性更好)
|
|
144
|
+
"B904", # 裸 except(某些情况下需要)
|
|
145
|
+
"W293", # 空行包含空白字符(某些情况下需要)
|
|
146
|
+
"UP007", # 已由 pyupgrade 自动处理
|
|
147
|
+
"UP035", # 已由 pyupgrade 自动处理
|
|
148
|
+
"UP037", # 已由 pyupgrade 自动处理
|
|
149
|
+
"RUF001", # 字符串中的全角标点(中文文档允许使用中文标点)
|
|
150
|
+
"RUF002", # 文档字符串中的全角标点(中文文档允许使用中文标点)
|
|
151
|
+
"RUF003", # 注释中的全角标点(中文注释允许使用中文标点)
|
|
152
|
+
"RUF012", # 可变类属性(SQLAlchemy 的 __mapper_args__ 是特殊属性,不需要 ClassVar)
|
|
153
|
+
"PYI034", # __aenter__ 返回类型(某些情况下需要返回具体类型)
|
|
154
|
+
]
|
|
155
|
+
unfixable = [
|
|
156
|
+
"F401", # 未使用的导入(某些情况下需要保留)
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
[tool.ruff.lint.pyupgrade]
|
|
160
|
+
# Python 3.13 语法升级配置
|
|
161
|
+
keep-runtime-typing = false # 允许将 typing 模块类型改为内置类型
|
|
162
|
+
|
|
163
|
+
[tool.ruff.lint.per-file-ignores]
|
|
164
|
+
"__init__.py" = [
|
|
165
|
+
"F401",
|
|
166
|
+
]
|
|
167
|
+
"tests/**/*.py" = [
|
|
168
|
+
"T201",
|
|
169
|
+
"F401",
|
|
170
|
+
"F811",
|
|
171
|
+
]
|
|
172
|
+
"scripts/**/*.py" = [
|
|
173
|
+
"T201",
|
|
174
|
+
]
|
|
175
|
+
"migrations/**/*.py" = [
|
|
176
|
+
"E501",
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
[tool.ruff.lint.isort]
|
|
180
|
+
known-first-party = [
|
|
181
|
+
"aury",
|
|
182
|
+
]
|
|
183
|
+
force-sort-within-sections = true
|
|
184
|
+
split-on-trailing-comma = true
|
|
185
|
+
|
|
186
|
+
[tool.ruff.lint.mccabe]
|
|
187
|
+
max-complexity = 15
|
|
188
|
+
|
|
189
|
+
[dependency-groups]
|
|
190
|
+
dev = [
|
|
191
|
+
"pytest>=9.0.1",
|
|
192
|
+
"pytest-asyncio>=1.3.0",
|
|
193
|
+
"pytest-cov>=7.0.0",
|
|
194
|
+
"ruff>=0.14.7",
|
|
195
|
+
"mypy>=1.19.0",
|
|
196
|
+
]
|
|
197
|
+
docs = [
|
|
198
|
+
"mkdocs>=1.6.1",
|
|
199
|
+
"mkdocs-material>=9.7.0",
|
|
200
|
+
"materialx>=1.39.4",
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
# ============================================================================
|
|
204
|
+
# 构建和发布配置
|
|
205
|
+
# ============================================================================
|
|
206
|
+
|
|
207
|
+
[build-system]
|
|
208
|
+
requires = [
|
|
209
|
+
"hatchling",
|
|
210
|
+
"hatch-vcs",
|
|
211
|
+
]
|
|
212
|
+
build-backend = "hatchling.build"
|
|
213
|
+
|
|
214
|
+
[tool.hatch.version]
|
|
215
|
+
source = "vcs"
|
|
216
|
+
|
|
217
|
+
[tool.hatch.build.hooks.vcs]
|
|
218
|
+
version-file = "aury/boot/_version.py"
|
|
219
|
+
|
|
220
|
+
[tool.hatch.build.targets.wheel]
|
|
221
|
+
packages = [
|
|
222
|
+
"aury",
|
|
223
|
+
]
|
|
224
|
+
|
|
225
|
+
[tool.hatch.build.targets.sdist]
|
|
226
|
+
include = [
|
|
227
|
+
"aum/",
|
|
228
|
+
"pyproject.toml",
|
|
229
|
+
"README.md",
|
|
230
|
+
"LICENSE",
|
|
231
|
+
]
|
|
232
|
+
exclude = [
|
|
233
|
+
"/.git",
|
|
234
|
+
"/.venv",
|
|
235
|
+
"/.idea",
|
|
236
|
+
"/.vscode",
|
|
237
|
+
"/.cursor",
|
|
238
|
+
"/.ruff_cache",
|
|
239
|
+
"/.mypy_cache",
|
|
240
|
+
"/.pytest_cache",
|
|
241
|
+
"/__pycache__",
|
|
242
|
+
"/dist",
|
|
243
|
+
"/build",
|
|
244
|
+
"/docs",
|
|
245
|
+
"/tests",
|
|
246
|
+
"/logs",
|
|
247
|
+
"*.egg-info",
|
|
248
|
+
"*.pyc",
|
|
249
|
+
"*.pyo",
|
|
250
|
+
".env*",
|
|
251
|
+
"*.bak",
|
|
252
|
+
"uv.lock",
|
|
253
|
+
"release.sh",
|
|
254
|
+
"pypi_key",
|
|
255
|
+
"WARP.md",
|
|
256
|
+
"LATEST_UPDATES.md",
|
|
257
|
+
"IMPLEMENTATION_SUMMARY.md",
|
|
258
|
+
"FOUNDATION_KIT_MISSING_FEATURES.md",
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
# 启用 keyring 提供者,自动从 keyring 读取凭据
|
|
262
|
+
keyring-provider = "subprocess"
|