uv-resolver: only serialize sdist for registry sourced distributions

This fixes an issue in the lock file where, in cases where we had a
non-registry sdist, the information in the sdist was strictly redundant
with the information in the source. This was born out in the code
already where the `sdist` field was only ever used to build a source
distribution type when the source was a registry. In all other cases,
the source distribution data can be materialized from the `source`
field.
This commit is contained in:
Andrew Gallant 2024-06-25 13:59:01 -04:00 committed by Andrew Gallant
parent 4899612619
commit 86c2a9b0b2

View file

@ -421,7 +421,12 @@ impl Lock {
table.insert("source", value(dist.id.source.to_string()));
if let Some(ref sdist) = dist.sdist {
table.insert("sdist", value(sdist.to_toml()?));
// An actual sdist entry in the lock file is only required when
// it's from a registry. Otherwise, it's strictly redundant
// with the information in all other kinds of `source`.
if matches!(dist.id.source, Source::Registry(_)) {
table.insert("sdist", value(sdist.to_toml()?));
}
}
if !dist.dependencies.is_empty() {