{"record":{"id":"c8d7f0eaa9f9e75c","repo":"astral-sh/uv","slug":"building-an-sdist-from-a-source-distribution-i","errorCode":null,"errorMessage":"Building an `--sdist` from a source distribution is not supported","messagePattern":"Building an `--sdist` from a source distribution is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv/src/commands/build_frontend.rs","lineNumber":1451,"sourceCode":"\n    /// Build a wheel from a source distribution.\n    WheelFromSdist,\n}\n\nimpl BuildPlan {\n    fn determine(source: &AnnotatedSource, sdist: bool, wheel: bool) -> Result<Self> {\n        Ok(match &source.source {\n            Source::File(_) => {\n                // We're building from a file, which must be a source distribution.\n                match (sdist, wheel) {\n                    (false, true) => Self::WheelFromSdist,\n                    (false, false) => {\n                        return Err(anyhow::anyhow!(\n                            \"Pass `--wheel` explicitly to build a wheel from a source distribution\"\n                        ));\n                    }\n                    (true, _) => {\n                        return Err(anyhow::anyhow!(\n                            \"Building an `--sdist` from a source distribution is not supported\"\n                        ));\n                    }\n                }\n            }\n            Source::Directory(_) => {\n                // We're building from a directory.\n                match (sdist, wheel) {\n                    (false, false) => Self::SdistToWheel,\n                    (false, true) => Self::Wheel,\n                    (true, false) => Self::Sdist,\n                    (true, true) => Self::SdistAndWheel,\n                }\n            }\n        })\n    }\n}\n","sourceCodeStart":1433,"sourceCodeEnd":1469,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv/src/commands/build_frontend.rs#L1433-L1469","documentation":"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.","triggerScenarios":"`uv build --sdist ./mypkg-1.0.tar.gz`; `uv build --sdist --wheel ./mypkg-1.0.tar.gz`.","commonSituations":"Mirroring pipelines that try to normalize artifacts by re-sdist-ing them; users assuming --sdist is the default everywhere and adding it defensively.","solutions":["Drop `--sdist` when the source is an archive; use `--wheel` (or nothing plus --wheel) to rebuild a wheel.","To produce a fresh sdist, run `uv build --sdist` against the project directory."],"exampleFix":"# before\nuv build --sdist ./mypkg-1.0.tar.gz\n# after\nuv build --wheel ./mypkg-1.0.tar.gz   # or: uv build --sdist ./  (from the project dir)","handlingStrategy":"validation","validationCode":"# Shell: reject --sdist for archive sources before invoking uv\nif [ -f \"$SRC\" ] && echo \" $@ \" | grep -q ' --sdist'; then\n  echo \"--sdist cannot be used with a source archive: $SRC\" >&2\n  exit 1\nfi\nuv build \"$@\" \"$SRC\"","typeGuard":"fn sdist_buildable(src: &Source) -> bool {\n    matches!(src, Source::Directory(_))\n}","tryCatchPattern":null,"preventionTips":["Never pass --sdist together with an archive path; run `uv build --sdist .` from the project instead.","Read the BuildPlan rules: file sources support exactly one valid mode — --wheel."],"tags":["build","sdist","cli-usage"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}