python
config_error
ai_generated
true
error: Multiple top-level packages discovered in a flat-layout: ['src', 'tests', 'docs'].
ID: python/setuptools-discovery-multiple-top-level
80%Fix Rate
89%Confidence
0Evidence
2024-01-09First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Setuptools auto-discovery in a flat layout finds more than one candidate package directory and refuses to guess which is the real one.
generic中文
Setuptools 在扁平布局中的自动发现找到多个候选包目录,拒绝猜测哪一个是真正的包。
Workarounds
-
97% success
[tool.setuptools] packages = ["mypkg"] # or [tool.setuptools.packages.find] where = ["src"] include = ["mypkg*"]
-
95% success
# move mypkg/ to src/mypkg/ [tool.setuptools.packages.find] where = ["src"]
Dead Ends
Common approaches that don't work:
-
85% fail
MANIFEST.in controls sdist contents, not setuptools package discovery.
-
90% fail
The discovery error occurs during build regardless of isolation.
-
70% fail
Discovery still finds src/ and _tests/ as candidates.