setuptools "package ... would be ignored" build warning in CI
setuptools warns that a directory it found is not recognized as an importable package and "would be ignored", so it is left out of the wheel. The result is an installable but broken distribution that is missing modules at import time.
What this error means
The build prints "package init file ... not found (or not a regular file)" or that a package "would be ignored", and the resulting wheel is missing modules, causing ModuleNotFoundError after install.
SetuptoolsDeprecationWarning: Installing 'mypkg.subpkg' as data is deprecated, please list it in `packages`.
!! 'mypkg.subpkg' would be ignored.Common causes
A subpackage has no __init__.py
setuptools treats a directory without __init__.py as data, not a package, so it is excluded unless you opt into namespace packages.
The package is not covered by find or packages
A directory outside the configured include/where discovery scope is silently dropped from the wheel.
How to fix it
Add __init__.py or widen discovery
- Add an
__init__.pyto each package directory. - Confirm the discovery
include/wherecovers it. - Rebuild and verify the wheel contains every module.
[tool.setuptools.packages.find]
where = ["src"]
include = ["mypkg*"]Inspect the wheel contents
List the wheel to confirm no package was dropped before publishing.
python -m build --wheel
unzip -l dist/*.whl | grep mypkg/How to prevent it
- Keep an
__init__.pyin every package directory. - Verify wheel contents in CI, not just that the build exits 0.
- Use explicit
findconfiguration over implicit discovery.