# 错误：无法为 foo 构建 wheel，而它是安装基于 pyproject.toml 的项目所必需的

- **ID:** `python/pip-legacy-install-failure-use-pep517`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

该包声明了带构建后端的 pyproject.toml（如 setuptools.build_meta、hatchling），但所需的构建依赖未安装，或构建后端在生成 wheel 阶段失败。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   Install build dependencies explicitly then retry: python -m pip install --upgrade pip setuptools wheel && python -m pip install foo
   ```
2. **** (90% 成功率)
   ```
   Inspect the failing build: python -m pip install -v foo and look for the actual backend traceback. Then install the missing backend (e.g. python -m pip install hatchling or flit-core) and retry.
   ```
3. **** (80% 成功率)
   ```
   Build in isolation with build: python -m pip install build && python -m build --wheel --no-isolation . to reproduce the backend error locally with full logs.
   ```

## 无效尝试

- **** — Disables isolation but if the build backend is missing from the current env, the build still fails — often with a more confusing error. (60% 失败率)
- **** — The wheel package is not the build backend here; installing it does not supply the missing build requirement. (85% 失败率)
