python config_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-08-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

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.

generic

中文

项目同时包含 pyproject.toml [project] 和 setup.py,且元数据冲突。setuptools 不会合并它们;TOML 优先,但不一致会触发错误。

Workarounds

  1. 95% success
    from setuptools import setup; setup()  # metadata in pyproject.toml
  2. 90% success
    [project]\ndynamic = ["version"]\n[tool.setuptools.dynamic]\nversion = {attr = "mypkg.__version__"}

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Build isolation does not resolve metadata conflicts.

  2. 50% fail

    If setup.py contains custom commands or dynamic fields, deleting it breaks the build.