python config_error ai_generated true

错误:在扁平布局中发现多个顶级包:['src', 'tests', 'docs']。

error: Multiple top-level packages discovered in a flat-layout: ['src', 'tests', 'docs'].

ID: python/setuptools-discovery-multiple-top-level

其他格式: JSON · Markdown 中文 · English
80%修复率
89%置信度
0证据数
2024-01-09首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

Setuptools 在扁平布局中的自动发现找到多个候选包目录,拒绝猜测哪一个是真正的包。

English

Setuptools auto-discovery in a flat layout finds more than one candidate package directory and refuses to guess which is the real one.

generic

解决方案

  1. 97% 成功率
    [tool.setuptools]
    packages = ["mypkg"]
    # or
    [tool.setuptools.packages.find]
    where = ["src"]
    include = ["mypkg*"]
  2. 95% 成功率
    # move mypkg/ to src/mypkg/
    [tool.setuptools.packages.find]
    where = ["src"]

无效尝试

常见但无效的做法:

  1. 85% 失败

    MANIFEST.in controls sdist contents, not setuptools package discovery.

  2. 90% 失败

    The discovery error occurs during build regardless of isolation.

  3. 70% 失败

    Discovery still finds src/ and _tests/ as candidates.