# FileNotFoundError：[Errno 2] 没有这样的文件或目录：sdist 安装期间 'mypkg/data/config.yaml'

- **ID:** `python/setuptools-manifest-in-missing-sdist-files`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

MANIFEST.in 未将数据文件包含在 sdist 中，因此安装的包缺少该文件。错误在运行时尝试打开文件时出现。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   echo 'recursive-include mypkg/data *.yaml' >> MANIFEST.in
   ```
2. **** (97% 成功率)
   ```
   [tool.setuptools.package-data]\nmypkg = ["data/*.yaml"]
   ```
3. **** (90% 成功率)
   ```
   python -m build --sdist && tar -tzf dist/*.tar.gz | grep config.yaml
   ```

## 无效尝试

- **** — Reinstalling the same incomplete sdist produces the same result. (90% 失败率)
- **** — Not reproducible; breaks on the next install. (60% 失败率)
