feat: 支持 uv 从 pyproject/requirements 创建虚拟环境
- 工作目录探测新增 pyproject.toml / requirements*.txt 扫描、uv 可用性与 can_create - 新增 POST /api/v1/python/venv/create:已有虚拟环境优先复用;pyproject 走 uv sync,requirements 走 uv venv + uv pip install,并使用默认 PyPI 镜像 - 编辑器在缺少虚拟环境且具备依赖文件时显示「用 uv 创建环境」;没有 uv 或没有依赖文件时明确报错 - 解释器字段改为可选,留空由服务端默认 python.exe 并使用虚拟环境;Python 任务缺少虚拟环境/依赖文件时运行直接失败,不再回退系统解释器 - 补后端探测/创建测试、前端入口测试与 README
This commit is contained in:
+82
-1
@@ -383,6 +383,46 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/python/venv/create": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"operationId": "create_python_venv",
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreatePythonVenvRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Created or reused project virtual environment",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VenvProbeResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Project cannot create a virtual environment",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/runs/{run_id}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -1155,6 +1195,19 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"CreatePythonVenvRequest": {
|
||||
"type": "object",
|
||||
"description": "用 uv 为项目创建 `.venv`(pyproject 用 uv sync,requirements 用 uv venv + uv pip install)。",
|
||||
"required": [
|
||||
"working_dir"
|
||||
],
|
||||
"properties": {
|
||||
"working_dir": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"CreateTaskRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -1959,9 +2012,18 @@
|
||||
"required": [
|
||||
"status",
|
||||
"interpreter_kind",
|
||||
"message"
|
||||
"message",
|
||||
"uv_available",
|
||||
"has_pyproject",
|
||||
"has_requirements",
|
||||
"requirements_files",
|
||||
"can_create"
|
||||
],
|
||||
"properties": {
|
||||
"can_create": {
|
||||
"type": "boolean",
|
||||
"description": "没有虚拟环境时,是否具备用 uv 创建的条件"
|
||||
},
|
||||
"display_path": {
|
||||
"type": [
|
||||
"string",
|
||||
@@ -1969,12 +2031,27 @@
|
||||
],
|
||||
"description": "供界面展示的解释器路径;位于工作目录内时使用相对路径"
|
||||
},
|
||||
"has_pyproject": {
|
||||
"type": "boolean",
|
||||
"description": "工作目录根部是否存在 pyproject.toml"
|
||||
},
|
||||
"has_requirements": {
|
||||
"type": "boolean",
|
||||
"description": "工作目录根部是否存在 requirements*.txt"
|
||||
},
|
||||
"interpreter_kind": {
|
||||
"$ref": "#/components/schemas/InterpreterKind"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"requirements_files": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "探测到的 requirements 文件名(仅根目录)"
|
||||
},
|
||||
"source": {
|
||||
"oneOf": [
|
||||
{
|
||||
@@ -1988,6 +2065,10 @@
|
||||
"status": {
|
||||
"$ref": "#/components/schemas/VenvProbeStatus"
|
||||
},
|
||||
"uv_available": {
|
||||
"type": "boolean",
|
||||
"description": "本机 PATH 中是否能找到 uv"
|
||||
},
|
||||
"venv_path": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
Reference in New Issue
Block a user