Skip to content
Latchkey

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.

build
* Building sdist...
ERROR Backend subprocess exited when trying to invoke build_sdist

Common 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

  1. Fetch tags and full history in the checkout step.
  2. Confirm the backend can compute a version.
  3. Re-run the sdist build.
.github/workflows/ci.yml
- 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.

Terminal
python -m build --sdist
# fix the file or version error printed by the backend

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →