python
config_error
ai_generated
true
错误:'name' 必须在 pyproject.toml 或 setup.py 中提供,但两者都存在且值不同
error: 'name' must be provided in pyproject.toml or setup.py, but both were found with different values
ID: python/setuptools-pyproject-and-setup-conflict
80%修复率
87%置信度
0证据数
2024-08-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
项目同时包含 pyproject.toml [project] 和 setup.py,且元数据冲突。setuptools 不会合并它们;TOML 优先,但不一致会触发错误。
English
The project has both pyproject.toml [project] and setup.py with conflicting metadata. setuptools does not merge them; the TOML takes precedence but inconsistency triggers errors.
解决方案
-
95% 成功率
from setuptools import setup; setup() # metadata in pyproject.toml
-
90% 成功率
[project]\ndynamic = ["version"]\n[tool.setuptools.dynamic]\nversion = {attr = "mypkg.__version__"}
无效尝试
常见但无效的做法:
-
90% 失败
Build isolation does not resolve metadata conflicts.
-
50% 失败
If setup.py contains custom commands or dynamic fields, deleting it breaks the build.