python
config_error
ai_generated
true
error: Multiple top-level packages discovered in a flat-layout: ['src', 'tests', 'docs'].
ID: python/pip-egg-info-directory-shadow
80%Fix Rate
88%Confidence
0Evidence
2024-10-03First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
setuptools auto-discovery in a flat project layout finds multiple candidate top-level packages and refuses to guess which one is the distribution.
generic中文
在扁平项目布局中,setuptools 自动发现找到多个候选的顶级包,拒绝猜测哪个是分发包。
Workarounds
-
95% success
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% success
mkdir -p src/mypkg mv mypkg/* src/mypkg/ # ensure pyproject.toml uses [tool.setuptools.packages.find] where=["src"] pip install .
Dead Ends
Common approaches that don't work:
-
85% fail
The error is from setuptools discovery, not isolation; the same 'Multiple top-level packages' error occurs.
-
70% fail
Hides one symptom but src/ and docs/ still trigger the error; brittle workaround.