# ERROR: setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['mypackage', 'mypackage2']

- **ID:** `python/setuptools-package-dir-conflict`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Setuptools auto-discovery finds multiple packages in the root directory, causing ambiguity.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **Explicitly specify packages in setup.cfg or setup.py** (95% success)
   ```
   In setup.cfg: [options]
packages = find:
find:
include = mypackage*
Or in setup.py: packages=['mypackage']
   ```
2. **Use namespace packages if both are related** (85% success)
   ```
   Rename packages to share a namespace like 'company.mypackage' and 'company.mypackage2'.
   ```

## Dead Ends

- **Renaming one package to a subpackage** — Does not resolve the discovery conflict; setuptools still sees two top-level packages. (70% fail)
- **Removing one package directory entirely** — Loss of code; better to configure explicitly. (50% fail)
