setuptools "package directory does not exist" in CI
setuptools tried to collect a package from a directory that does not exist in the build tree. This usually means packages lists a name with no matching folder, or package_dir points at a src path that the manifest or checkout does not contain.
What this error means
The build fails with "error: package directory 'mypkg' does not exist" or "package directory 'src/mypkg' does not exist", naming a path setuptools expected but could not find.
error: package directory 'src/mypkg' does not existCommon causes
packages names a folder that is not there
You listed mypkg in packages, but the directory is named differently or lives under src/. setuptools looks where you told it and finds nothing.
package_dir and the real layout disagree
A package_dir = {"" : "src"} mapping expects code under src/, but the package sits at the repo root (or vice versa), so the resolved path is wrong.
How to fix it
Align package_dir with the actual layout
- Check where your package directory actually lives in the repo.
- Set
package_dirandwhereto match that location. - Re-run the build to confirm the path resolves.
[tool.setuptools]
package-dir = {"" = "src"}
[tool.setuptools.packages.find]
where = ["src"]Confirm the directory is in the sdist
If building from an sdist, make sure MANIFEST.in or the build includes the package directory; a missing file in the tarball produces the same error.
python -m build --sdist
tar tzf dist/*.tar.gz | grep mypkg/How to prevent it
- Keep
package_dir/wherein sync with the real folder layout. - Verify the sdist contains your package before publishing.
- Use auto-discovery with a clean src layout to avoid manual path lists.