astral-sh/uv · error

Building an `--sdist` from a source distribution is not supp

Error message

Building an `--sdist` from a source distribution is not supported

What it means

BuildPlan::determine rejects `(sdist=true, *)` when the source is a file: an sdist archive cannot itself be packed into another sdist — only wheel builds from sdists are supported. Any combination with --sdist on a file source (with or without --wheel) hits this arm.

Source

Thrown at crates/uv/src/commands/build_frontend.rs:1451

    /// Build a wheel from a source distribution.
    WheelFromSdist,
}

impl BuildPlan {
    fn determine(source: &AnnotatedSource, sdist: bool, wheel: bool) -> Result<Self> {
        Ok(match &source.source {
            Source::File(_) => {
                // We're building from a file, which must be a source distribution.
                match (sdist, wheel) {
                    (false, true) => Self::WheelFromSdist,
                    (false, false) => {
                        return Err(anyhow::anyhow!(
                            "Pass `--wheel` explicitly to build a wheel from a source distribution"
                        ));
                    }
                    (true, _) => {
                        return Err(anyhow::anyhow!(
                            "Building an `--sdist` from a source distribution is not supported"
                        ));
                    }
                }
            }
            Source::Directory(_) => {
                // We're building from a directory.
                match (sdist, wheel) {
                    (false, false) => Self::SdistToWheel,
                    (false, true) => Self::Wheel,
                    (true, false) => Self::Sdist,
                    (true, true) => Self::SdistAndWheel,
                }
            }
        })
    }
}

View on GitHub (pinned to f1a42680ff)

Solutions

  1. Drop `--sdist` when the source is an archive; use `--wheel` (or nothing plus --wheel) to rebuild a wheel.
  2. To produce a fresh sdist, run `uv build --sdist` against the project directory.

Example fix

# before
uv build --sdist ./mypkg-1.0.tar.gz
# after
uv build --wheel ./mypkg-1.0.tar.gz   # or: uv build --sdist ./  (from the project dir)
Defensive patterns

Strategy: validation

Validate before calling

# Shell: reject --sdist for archive sources before invoking uv
if [ -f "$SRC" ] && echo " $@ " | grep -q ' --sdist'; then
  echo "--sdist cannot be used with a source archive: $SRC" >&2
  exit 1
fi
uv build "$@" "$SRC"

Type guard

fn sdist_buildable(src: &Source) -> bool {
    matches!(src, Source::Directory(_))
}

Prevention

When it happens

Trigger: `uv build --sdist ./mypkg-1.0.tar.gz`; `uv build --sdist --wheel ./mypkg-1.0.tar.gz`.

Common situations: Mirroring pipelines that try to normalize artifacts by re-sdist-ing them; users assuming --sdist is the default everywhere and adding it defensively.

Related errors


AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16). Data as JSON: /api/errors/c8d7f0eaa9f9e75c. Report an issue: GitHub.