python -m build "Backend build_sdist failed" in CI
The PEP 517 frontend called the backend's build_sdist hook and it exited non-zero. The summary is generic; the real error (a missing file, a version source it cannot read, or a VCS that is unavailable) is in the backend output above the summary line.
What this error means
A python -m build --sdist (or full build) run fails with "ERROR Backend subprocess exited when trying to invoke build_sdist" and a backend traceback above it.
* Building sdist...
ERROR Backend subprocess exited when trying to invoke build_sdistCommon causes
A version source the backend cannot read
Backends like setuptools_scm or hatch-vcs read the version from git. In a shallow or tagless checkout the sdist step fails.
Files the sdist references are missing
A MANIFEST.in include or a declared file that is absent in the build tree makes source collection fail.
How to fix it
Provide git history for VCS version backends
- Fetch tags and full history in the checkout step.
- Confirm the backend can compute a version.
- Re-run the sdist build.
- uses: actions/checkout@v4
with: { fetch-depth: 0, fetch-tags: true }Read the backend error and fix the missing file
Run the sdist locally to see the real cause and correct the MANIFEST or path.
python -m build --sdist
# fix the file or version error printed by the backendHow to prevent it
- Use a full-history checkout when the version comes from VCS.
- Keep MANIFEST.in and packaged files in sync with the tree.
- Build the sdist in CI on every push.