{
  "id": "python/setuptools-package-discovery-error",
  "signature": "error: Multiple top-level packages discovered in a flat-layout: ['foo', 'tests'].",
  "signature_zh": "错误：在扁平布局中发现了多个顶层包：['foo', 'tests']。",
  "regex": "error:\\ Multiple\\ top\\-level\\ packages\\ discovered\\ in\\ a\\ flat\\-layout:\\ \\['foo',\\ 'tests'\\]\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "With setuptools' automatic package discovery, a flat project layout containing more than one top-level directory (e.g. the package and a `tests`/`docs` dir) is ambiguous, so setuptools refuses to guess.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 setuptools 的自动包发现下，包含多个顶层目录（如包目录和 `tests`/`docs`）的扁平项目布局存在歧义，因此 setuptools 拒绝猜测。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Loses test code and does not address the discovery ambiguity.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May still collide with other top-level dirs and is a cosmetic change.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Declare packages explicitly in pyproject.toml: `[tool.setuptools.packages.find] include = [\"foo*\"] exclude = [\"tests*\"]`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Move the package into a `src/` layout and set `[tool.setuptools.packages.find] where = [\"src\"]`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}