python
config_error
ai_generated
true
错误:在扁平布局中发现多个顶级包:['src', 'tests', 'docs']。
error: Multiple top-level packages discovered in a flat-layout: ['src', 'tests', 'docs'].
ID: python/pip-egg-info-directory-shadow
80%修复率
88%置信度
0证据数
2024-10-03首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
在扁平项目布局中,setuptools 自动发现找到多个候选的顶级包,拒绝猜测哪个是分发包。
English
setuptools auto-discovery in a flat project layout finds multiple candidate top-level packages and refuses to guess which one is the distribution.
解决方案
-
95% 成功率
cat > pyproject.toml <<'TOML' [build-system] requires = ["setuptools>=68"] build-backend = "setuptools.build_meta" [project] name = "mypkg" version = "0.1.0" [tool.setuptools.packages.find] where = ["src"] TOML pip install .
-
90% 成功率
mkdir -p src/mypkg mv mypkg/* src/mypkg/ # ensure pyproject.toml uses [tool.setuptools.packages.find] where=["src"] pip install .
无效尝试
常见但无效的做法:
-
85% 失败
The error is from setuptools discovery, not isolation; the same 'Multiple top-level packages' error occurs.
-
70% 失败
Hides one symptom but src/ and docs/ still trigger the error; brittle workaround.