python config_error ai_generated true

error: Multiple top-level packages discovered in a flat-layout: ['package1', 'package2'].

ID: python/setuptools-long-description-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-05-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

setuptools automatically discovers packages but finds multiple in the same directory, causing ambiguity.

generic

中文

setuptools 自动发现包,但在同一目录中找到多个,导致歧义。

Workarounds

  1. 90% success Explicitly specify packages in setup.py or setup.cfg
    In setup.cfg, add '[options]\npackages = find:' and configure find options, or list packages manually.
  2. 85% success Use a src-layout
    Move packages into a 'src/' directory and set 'package_dir = {"": "src"}' in setup.cfg.

Dead Ends

Common approaches that don't work:

  1. Ignoring the warning and proceeding 80% fail

    setuptools may fail to build or include wrong packages.

  2. Renaming the packages to have a common prefix 60% fail

    This does not resolve the flat-layout detection logic.