# 错误：[Errno 2] 没有那个文件或目录：'setup.py'

错误：为某些基于 pyproject.toml 的项目（foo）构建可安装 wheel 失败

- **ID:** `python/pip-egg-info-failed-setup-py`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

构建后端需要 setup.py（旧式 setuptools），但包只有 pyproject.toml，或者构建后端被错误配置为使用 setuptools.build_meta:__legacy__。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Fix the build-system table in pyproject.toml:
  [build-system]
  requires = ["setuptools>=61", "wheel"]
  build-backend = "setuptools.build_meta"
(Not __legacy__, which requires setup.py.)
   ```
2. **** (85% 成功率)
   ```
   If you maintain the package, switch to a modern backend (hatchling, poetry-core, flit) that does not need setup.py.
   ```

## 无效尝试

- **** — An empty setup.py does not declare metadata; the build produces an unusable package. (80% 失败率)
- **** — Isolation is not the issue; the backend cannot find the file it expects. (70% 失败率)
