fix: 更新依赖项管理,优化 pyproject.toml 和 requirements.txt 文件

This commit is contained in:
晴猫
2026-03-15 07:18:12 +09:00
parent 1978b097e3
commit 14c85e388f
3 changed files with 27 additions and 23 deletions

View File

@@ -1,20 +1,26 @@
[build-system]
requires = ["setuptools>=80.9.0"]
build-backend = "setuptools.build_meta"
[project]
name = "MaiBot"
version = "1.0.0"
description = "MaiCore 是一个基于大语言模型的可交互智能体"
requires-python = ">=3.10"
dependencies = [
"aiohttp-cors>=0.8.1",
"aiohttp>=3.12.14",
"Babel>=2.17.0",
"aiohttp>=3.12.14",
"certifi",
"colorama>=0.4.6",
"faiss-cpu>=1.11.0",
"fastapi>=0.116.0",
"google-genai>=1.39.1",
"httpx",
"jieba>=0.42.1",
"json-repair>=0.47.6",
"maim-message>=0.6.2",
"matplotlib>=3.10.3",
"maibot-plugin-sdk>=1.2.3",
"msgpack>=1.1.2",
"numpy>=2.2.6",
"openai>=1.95.0",
"pandas>=2.3.1",
@@ -25,21 +31,23 @@ dependencies = [
"python-dotenv>=1.1.1",
"python-multipart>=0.0.20",
"python-levenshtein",
"pytz>=2024.1", # Babel 的依赖,需要显式声明
"quick-algo>=0.1.4",
"rich>=14.0.0",
"ruff>=0.12.2",
"setuptools>=80.9.0",
"sqlalchemy>=2.0.40",
"sqlmodel>=0.0.24",
"structlog>=25.4.0",
"toml>=0.10.2",
"tomlkit>=0.13.3",
"urllib3>=2.5.0",
"typing-extensions",
"uvicorn>=0.35.0",
"msgpack>=1.1.2",
"watchfiles>=1.1.1",
"maibot-plugin-sdk>=1.2.3",
]
[dependency-groups]
dev = [
"pytest",
"pytest-asyncio",
"ruff>=0.12.2",
"zstandard",
]

View File

@@ -1,15 +1,15 @@
Babel>=2.17.0
aiohttp-cors>=0.8.1
aiohttp>=3.12.14
certifi
colorama>=0.4.6
faiss-cpu>=1.11.0
fastapi>=0.116.0
google-genai>=1.39.1
httpx
jieba>=0.42.1
json-repair>=0.47.6
maibot-plugin-sdk>=1.2.3
maim-message>=0.6.2
matplotlib>=3.10.3
maibot-plugin-sdk>=1.2.3
msgpack>=1.1.2
numpy>=2.2.6
openai>=1.95.0
@@ -19,18 +19,14 @@ pyarrow>=20.0.0
pydantic>=2.11.7
pypinyin>=0.54.0
python-dotenv>=1.1.1
python-levenshtein
python-multipart>=0.0.20
pytz>=2024.1
python-levenshtein
quick-algo>=0.1.4
rich>=14.0.0
ruff>=0.12.2
setuptools>=80.9.0
sqlalchemy>=2.0.40
sqlmodel>=0.0.24
structlog>=25.4.0
toml>=0.10.2
tomlkit>=0.13.3
urllib3>=2.5.0
typing-extensions
uvicorn>=0.35.0
watchfiles>=1.1.1

View File

@@ -8,7 +8,7 @@ def generate_requirements(pyproject_path="pyproject.toml", output_path="requirem
pyproject_data = tomlkit.load(file)
# 获取 pyproject.toml 中的 dependencies 列表
pyproject_dependencies = set(pyproject_data.get("project", {}).get("dependencies", []))
pyproject_dependencies = pyproject_data.get("project", {}).get("dependencies", [])
if not pyproject_dependencies:
print("未找到 dependencies 部分,无法生成 requirements.txt")
return
@@ -20,14 +20,14 @@ def generate_requirements(pyproject_path="pyproject.toml", output_path="requirem
except FileNotFoundError:
requirements = set()
if extra_dependencies := requirements - pyproject_dependencies:
if extra_dependencies := requirements - set(pyproject_dependencies):
print("警告: 以下依赖项存在于 requirements.txt 中,但未在 pyproject.toml 中找到:")
for dep in extra_dependencies:
print(f" - {dep}")
# 写入更新后的 requirements.txt 文件
with open(output_path, "w", encoding="utf-8") as file:
file.write("\n".join(sorted(pyproject_dependencies)))
file.write("\n".join(pyproject_dependencies))
print(f"requirements.txt 文件已生成: {output_path}")
except FileNotFoundError: