From b9fcd68418f50835428753d86f674b7c527c6b55 Mon Sep 17 00:00:00 2001 From: liqiang-fit2cloud Date: Tue, 19 Aug 2025 15:50:41 +0800 Subject: [PATCH] build: try uv. --- installer/Dockerfile | 5 +- pyproject.toml | 154 ++++++++++++++++++++----------------------- 2 files changed, 72 insertions(+), 87 deletions(-) diff --git a/installer/Dockerfile b/installer/Dockerfile index 840ccb64..a9abd5ca 100644 --- a/installer/Dockerfile +++ b/installer/Dockerfile @@ -21,10 +21,9 @@ COPY --chmod=700 . /opt/maxkb-app WORKDIR /opt/maxkb-app RUN rm -rf /opt/maxkb-app/ui && \ python3 -m venv /opt/py3 && \ - pip install poetry==2.0.0 --break-system-packages && \ - poetry config virtualenvs.create false && \ + pip install uv --break-system-packages && \ . /opt/py3/bin/activate && \ - poetry install && \ + uv sync && \ find /opt/maxkb-app -depth \( -name ".git*" -o -name ".docker*" -o -name ".idea*" -o -name ".editorconfig*" -o -name ".prettierrc*" -o -name "README.md" -o -name "poetry.lock" -o -name "pyproject.toml" \) -exec rm -rf {} + && \ export MAXKB_CONFIG_TYPE=ENV && python3 /opt/maxkb-app/apps/manage.py compilemessages && \ export PIP_TARGET=/opt/maxkb-app/sandbox/python-packages && \ diff --git a/pyproject.toml b/pyproject.toml index 24d1c84e..425282b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,93 +1,79 @@ -[tool.poetry] +[project] name = "maxkb" version = "2.0.0" description = "强大易用的开源企业级智能体平台" -authors = ["shaohuzhang1 "] +authors = [{ name = "shaohuzhang1", email = "shaohu.zhang@fit2cloud.com" }] +requires-python = "~=3.11.0" readme = "README.md" -package-mode = false - -[tool.poetry.dependencies] -python = "^3.11" - -# Web框架 -django = "5.2.4" -drf-spectacular = { extras = ["sidecar"], version = "0.28.0" } -django-redis = "6.0.0" -django-db-connection-pool = "1.2.6" -django-mptt = "0.17.0" -psycopg = { extras = ["binary"], version = "3.2.9" } - -# 工具库 -python-dotenv = "1.1.1" -uuid-utils = "0.11.0" -captcha = "0.7.1" -pytz = "2025.2" -psutil = "7.0.0" -cffi = "1.17.1" -beautifulsoup4 = "4.13.4" -jieba = "0.42.1" - -# LLM及AI相关 -langchain-openai = "0.3.27" -langchain-anthropic = "0.3.17" -langchain-community = "0.3.27" -langchain-deepseek = "0.1.3" -langchain-google-genai = "2.1.7" -langchain-mcp-adapters = "0.1.9" -langchain-huggingface = "0.3.0" -langchain-ollama = "0.3.4" -langgraph = "0.5.3" -torch = [ - { version = "2.8.0+cpu", markers = "sys_platform == 'linux'", source = "pytorch" }, - { version = "2.8.0+cpu", markers = "sys_platform == 'win'", source = "pytorch" }, - { url = "https://download.pytorch.org/whl/cpu/torch-2.8.0-cp311-none-macosx_11_0_arm64.whl", markers = "sys_platform == 'darwin'" }, +dependencies = [ + "django==5.2.4", + "drf-spectacular[sidecar]==0.28.0", + "django-redis==6.0.0", + "django-db-connection-pool==1.2.6", + "django-mptt==0.17.0", + "psycopg[binary]==3.2.9", + "python-dotenv==1.1.1", + "uuid-utils==0.11.0", + "captcha==0.7.1", + "pytz==2025.2", + "psutil==7.0.0", + "cffi==1.17.1", + "beautifulsoup4==4.13.4", + "jieba==0.42.1", + "langchain-openai==0.3.27", + "langchain-anthropic==0.3.17", + "langchain-community==0.3.27", + "langchain-deepseek==0.1.3", + "langchain-google-genai==2.1.7", + "langchain-mcp-adapters==0.1.9", + "langchain-huggingface==0.3.0", + "langchain-ollama==0.3.4", + "langgraph==0.5.3", + "torch=2.8.0", + "sentence-transformers==5.0.0", + "qianfan==0.4.12.3", + "zhipuai==2.1.5.20250708", + "volcengine-python-sdk[ark]==4.0.5", + "boto3==1.39.4", + "tencentcloud-sdk-python==3.0.1420", + "tencentcloud-sdk-python-asr==3.0.1416", + "xinference-client==1.7.1.post1", + "anthropic==0.57.1", + "dashscope==1.23.8", + "celery[sqlalchemy]==5.5.3", + "django-celery-beat==2.8.1", + "celery-once==3.0.1", + "django-apscheduler==0.7.0", + "html2text==2025.4.15", + "openpyxl==3.1.5", + "python-docx==1.2.0", + "xlrd==2.0.2", + "xlwt==1.3.0", + "pymupdf==1.26.3", + "pypdf==6.0.0", + "pydub==0.25.1", + "pysilk==0.0.1", + "gunicorn==23.0.0", + "python-daemon==3.1.2", + "websockets==15.0.1", + "pylint==3.3.7", ] -sentence-transformers = "5.0.0" -# 云服务SDK -qianfan = "0.4.12.3" -zhipuai = "2.1.5.20250708" -volcengine-python-sdk = {version = "4.0.5", extras = ["ark"]} -boto3 = "1.39.4" -tencentcloud-sdk-python = "3.0.1420" -tencentcloud-sdk-python-asr = "3.0.1416" -xinference-client = "1.7.1.post1" -anthropic = "0.57.1" -dashscope = "1.23.8" +[tool.uv] +package = false -# 异步任务 -celery = { extras = ["sqlalchemy"], version = "5.5.3" } -django-celery-beat = "2.8.1" -celery-once = "3.0.1" -django-apscheduler = "0.7.0" - -# 文档处理 -html2text = "2025.4.15" -openpyxl = "3.1.5" -python-docx = "1.2.0" -xlrd = "2.0.2" -xlwt = "1.3.0" -pymupdf = "1.26.3" -pypdf = "6.0.0" - -# 音频处理 -pydub = "0.25.1" -pysilk = "0.0.1" - -# 部署工具 -gunicorn = "23.0.0" -python-daemon = "3.1.2" -websockets = "15.0.1" - -# 开发工具 -pylint = "3.3.7" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" - -[[tool.poetry.source]] +[[tool.uv.index]] name = "pytorch" url = "https://download.pytorch.org/whl/cpu" -priority = "explicit" \ No newline at end of file +explicit = true + +[tool.uv.sources] +torch = [ + { index = "pytorch", marker = "sys_platform == 'linux'" }, + { index = "pytorch", marker = "sys_platform == 'win'" }, + { url = "https://download.pytorch.org/whl/cpu/torch-2.8.0-cp311-none-macosx_11_0_arm64.whl", marker = "sys_platform == 'darwin'" }, +] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" \ No newline at end of file