# 错误：在扁平布局中发现多个顶级包：['src', 'tests', 'docs']。

- **ID:** `python/setuptools-package-discovery-flat-layout`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

当多个同级目录看起来像包时，setuptools 自动发现拒绝猜测哪个顶级目录是真正的包；需要显式配置。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   [tool.setuptools.packages.find]
where = ["src"]
include = ["mypkg*"]
# or list them
[tool.setuptools]
packages = ["mypkg"]
   ```
2. **** (94% 成功率)
   ```
   mkdir -p src/mypkg
mv mypkg/* src/mypkg/
touch src/mypkg/__init__.py
# then configure
[tool.setuptools.packages.find]
where = ["src"]
   ```

## 无效尝试

- **** — Works around the symptom but breaks conventional tooling and CI that expect those names. (60% 失败率)
- **** — Makes the ambiguity worse; setuptools now sees even more candidate packages. (80% 失败率)
