Skip to content

Commit 8041143

Browse files
committed
fix(python): 识别仅有 Conda 清单的项目
1 parent 2b9788a commit 8041143

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Python Support v1.0.0 requires Lithe 0.8.9 or later. Lithe 0.8.9 can install the
3333
- `lithe/build/test`:通过 pytest node ID 精确运行套件或单个用例,也接受 JUnit XML 类名。指定用例时须同时给出套件。运行时推送 `lithe/build/progress`,并产出 `.pytest_cache/lithe-junit.xml` 供 Core 解码。构建请求在排队时即可取消,执行进程的所有权随请求结束。macOS 和 Linux 使用 POSIX 进程组,Windows 使用 Job Object。
3434
- 顶部「当前文件 → 运行」支持带 `__main__` 入口的脚本和包内 `__main__.py`。`lithe/build/runEntrypoints` 静态发现入口,`lithe/build/prepareRun` 返回启动计划。默认使用项目选定的 Python;指定「Python 解释器覆盖」时,使用宿主解析的显式解释器。
3535
- `scripts/run_entrypoint.py` 随插件 ZIP 安装,运行时只读。它在宿主管理的进程树内转发解释器覆盖,并检查包入口的实际来源。包名被其他模块遮蔽时给出错误。旧宿主未传界面语言时,入口错误同时提供中英文。
36+
- 仅用 `environment.yml` 或 `environment.yaml` 管理 Conda 环境的项目也会识别为 Python 构建实例。
3637
- 在「运行/调试配置 → + → Python」手动配置脚本路径或模块名。可设置解释器选项、脚本参数、工作目录和环境变量。运行时沿用项目的 Python 工具链及解释器覆盖设置,支持选用 Conda、uv 和普通虚拟环境。
3738
- 构建面板的「依赖」显示所选解释器中已安装的 Python 包版本与依赖关系。展开或重新加载时读取发行包元数据,支持无 pip 的环境。包共享的子树只展开一次,循环依赖以叶节点结束。
3839
- 同时保留声明式任务 `pip install -r requirements.txt` 与 `mypy`(带诊断 `lineMatcher`)。

‎docs/feature-matrix.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
| 构建模型与运行 (`buildSystems: python` + `provider`) | `scripts/build_provider.py`(`python -I -B`,`lithe/build/model`)复用 `scripts/build_model.py` 纯 AST + `tomllib` / `vendor/tomli` 静态提取 `[project.scripts]`、包 `__main__.py`、顶层 `__main__` 脚本、Django `manage.py`、FastAPI ASGI、Flask WSGI 并派生 7 类声明式 `run` 配置;支持损坏 `pyproject.toml` 降级与修复后恢复诊断,并在协商 `litheBuild` 1 时支持 `lithe/build/runEntrypoints` | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/scripts/build_model.py`<br>`io.github.lithe-idea.python-support/scripts/build_provider.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
2020
| 当前文件运行 (`buildProviders: 1`) | 工具栏支持带 `__main__` 入口的脚本或包内 `__main__.py`。使用项目 Python 或经宿主解析的显式解释器。包入口执行前核对文件来源。 | ✅ 已验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | 2026-11-20(macOS ARM64,Lithe 0.8.9、0.8.11 工作台端到端) | `io.github.lithe-idea.python-support/scripts/build_provider.py`<br>`io.github.lithe-idea.python-support/scripts/run_entrypoint.py`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_current_file_run_e2e_test.go` |
2121
| 手动 Python 运行配置 (`runConfigurationTypes: 0`) | 「运行/调试配置 → + → Python」支持脚本路径和模块名、解释器选项、参数、环境变量和工作目录。使用项目选定的解释器或插件解释器覆盖设置。 | ✅ 已验证(macOS ARM64) | ⏳ 待实机验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | 2026-11-21(固定宿主,脚本与模块) | `io.github.lithe-idea.python-support/plugin.json`<br>`e2e/host/desktop/internal/workbench/python_project_workflow_e2e_test.go` |
22-
| 构建面板依赖树 (`litheDependencies`) | 展开「依赖」时读取所选 Python 环境中已安装的包、版本和依赖关系,解析 PEP 508 条件和可选依赖。支持无 pip 的环境。 | ✅ 已验证(macOS ARM64) | ⏳ 待实机验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | 2026-11-21(固定宿主与打包命令) | `io.github.lithe-idea.python-support/scripts/dependencies.py`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_project_workflow_e2e_test.go` |
22+
| 构建面板依赖树 (`litheDependencies`) | 展开「依赖」时读取所选 Python 环境中已安装的包、版本和依赖关系,解析 PEP 508 条件和可选依赖。仅有 Conda 环境清单的项目也可加载。支持无 pip 的环境。 | ✅ 已验证(macOS ARM64) | ⏳ 待实机验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | 2026-11-21(固定宿主与打包命令) | `io.github.lithe-idea.python-support/scripts/dependencies.py`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_project_workflow_e2e_test.go` |
2323
| 动态 `pytest` 测试树与测试执行 (`litheTestDiscovery` + `junitXml`) | `test.discoveryCommand` 通过 `python -I -B` 启动包内 `discover_tests.py`。`pytest --collect-only` 收集函数、类方法、参数化用例与 doctest,并将 `litheTestDiscovery` v0 写入宿主提供的 `${outputFile}`。无测试时返回空列表,收集失败或选择器超出契约时整次失败。报告与缓存由宿主清理。`lithe/build/test` 以精确 node ID 或 JUnit 类名重跑,继续提供流式进度和 JUnit 报告。 | ✅ 已验证(桌面主线) | ⏳ 待实机验证 | ⏳ 待 CI 与宿主验收 | ⏳ 待 CI 与宿主验收 | 2026-11-20(macOS ARM64,桌面主线) | `io.github.lithe-idea.python-support/scripts/discover_tests.py`<br>`io.github.lithe-idea.python-support/scripts/build_provider.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
2424
| 独立工具构建系统 (`uv` / `conda` / `ruff`) | `uv`(`sync` / `lock`)、`conda`(`env update --file environment.yml --prune`)、`ruff`(`check` 含 `lineMatcher` / `format`)按各自标记文件独立检测与规划 | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
2525
| 调试器 (`debugAdapters: debugpy`) | 内置打包 `debugpy` `1.8.22`(`stdio` DAP,`["-I", "-B"]` + `scripts/debugpy_adapter.py`、`--log-dir ${logDir}`、适配器与 `launch` 双重设置 `PYTHONDONTWRITEBYTECODE=1` 保持插件目录零写入、支持远程 `attach` + `pathMappings`) | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | 2026-11-20(macOS ARM64,桌面主线) | `io.github.lithe-idea.python-support/plugin.json`<br>`io.github.lithe-idea.python-support/scripts/debugpy_adapter.py`<br>`vendor-lock.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go`<br>`e2e/host/desktop/internal/workbench/python_editor_debug_e2e_test.go` |

‎e2e/host/desktop/internal/workbench/python_project_workflow_e2e_test.go‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ func TestPythonSupportPluginManualRunAndDependencies(t *testing.T) {
5454
}
5555
}
5656
program := "import os, sys\nprint(sys.prefix)\nprint(os.getcwd())\nprint(sys.flags.dev_mode, os.environ['PROFILE_TEST'], repr(sys.argv[1:]))\n"
57-
write(filepath.Join(root, "requirements.txt"), "root-demo==1.0\n")
57+
// A Conda environment file is this workspace's only build marker.
58+
write(filepath.Join(root, "environment.yml"), "name: manual-run\ndependencies:\n - python\n")
5859
write(filepath.Join(root, "manual script.py"), program)
5960
write(filepath.Join(work, "manual_module.py"), program)
6061
purelib := strings.TrimSpace(string(site))
@@ -169,18 +170,22 @@ func TestPythonSupportPluginManualRunAndDependencies(t *testing.T) {
169170
})
170171
}
171172

172-
var instance *buildInstance
173+
var instanceIndex int
173174
awaitStateWithin(t, h, 10*time.Second, "the Python model with a project", func() bool {
174175
for index := range p.build.instances {
175176
candidate := &p.build.instances[index]
176177
if candidate.BuildSystemID == "python" && candidate.modelLoaded && len(candidate.Model.Projects) == 1 {
177-
instance = candidate
178+
instanceIndex = index
178179
return true
179180
}
180181
}
181182
return false
182183
})
183-
h.app.post(func(a *App) { a.reduceChrome(core.SetChromeOpen(itemBuild, true)) })
184+
instance := &p.build.instances[instanceIndex]
185+
h.app.post(func(a *App) {
186+
a.selectBuildInstance(p, instanceIndex)
187+
a.reduceChrome(core.SetChromeOpen(itemBuild, true))
188+
})
184189
var section buildRow
185190
awaitStateWithin(t, h, 10*time.Second, "the Dependencies section in the Build panel", func() bool {
186191
rows, _ := h.app.buildTreeRows(p)

‎io.github.lithe-idea.python-support/plugin.json‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@
483483
"displayName": "Python",
484484
"icon": { "path": "icons/python.svg" },
485485
"detection": {
486-
"markers": ["pyproject.toml", "setup.py", "setup.cfg", "requirements.txt"]
486+
"markers": [
487+
"pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "environment.yml", "environment.yaml"
488+
]
487489
},
488490
"invocation": {
489491
"executables": [
@@ -737,7 +739,9 @@
737739
]
738740
},
739741
"sync": {
740-
"watch": ["pyproject.toml", "setup.py", "setup.cfg", "requirements.txt"]
742+
"watch": [
743+
"pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "environment.yml", "environment.yaml"
744+
]
741745
},
742746
"layout": {
743747
"excluded": [".venv", "venv", ".conda"],

0 commit comments

Comments
 (0)