python
config_error
ai_generated
true
错误:在扁平布局中发现多个顶级包:['src', 'tests', 'docs']。
error: Multiple top-level packages discovered in a flat-layout: ['src', 'tests', 'docs'].
ID: python/setuptools-discovery-multiple-top-level
80%修复率
89%置信度
0证据数
2024-01-09首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
Setuptools 在扁平布局中的自动发现找到多个候选包目录,拒绝猜测哪一个是真正的包。
English
Setuptools auto-discovery in a flat layout finds more than one candidate package directory and refuses to guess which is the real one.
解决方案
-
97% 成功率
[tool.setuptools] packages = ["mypkg"] # or [tool.setuptools.packages.find] where = ["src"] include = ["mypkg*"]
-
95% 成功率
# move mypkg/ to src/mypkg/ [tool.setuptools.packages.find] where = ["src"]
无效尝试
常见但无效的做法:
-
85% 失败
MANIFEST.in controls sdist contents, not setuptools package discovery.
-
90% 失败
The discovery error occurs during build regardless of isolation.
-
70% 失败
Discovery still finds src/ and _tests/ as candidates.