Skip to content

Commit

Permalink
Fix sdist build for optional path dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Sep 6, 2022
1 parent 7d92871 commit 15f6b3e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ fn rewrite_cargo_toml(
dep_name
)
}
// This is the location of the targeted crate in the source distribution
table[&dep_name]["path"] = if root_crate {
toml_edit::value(format!("{}/{}", LOCAL_DEPENDENCIES_FOLDER, dep_name))
} else {
// Cargo.toml contains relative paths, and we're already in LOCAL_DEPENDENCIES_FOLDER
toml_edit::value(format!("../{}", dep_name))
};
rewritten = true;
if !known_path_deps.contains_key(&dep_name) {
// Ignore optional indirect dependencies
if !root_crate
&& table[&dep_name]
.get("optional")
.and_then(|x| x.as_bool())
.unwrap_or_default()
{
continue;
}
bail!(
"cargo metadata does not know about the path for {}.{} present in {}, \
which should never happen ಠ_ಠ",
Expand All @@ -75,6 +76,14 @@ fn rewrite_cargo_toml(
manifest_path.as_ref().display()
);
}
// This is the location of the targeted crate in the source distribution
table[&dep_name]["path"] = if root_crate {
toml_edit::value(format!("{}/{}", LOCAL_DEPENDENCIES_FOLDER, dep_name))
} else {
// Cargo.toml contains relative paths, and we're already in LOCAL_DEPENDENCIES_FOLDER
toml_edit::value(format!("../{}", dep_name))
};
rewritten = true;
}
}
}
Expand Down

0 comments on commit 15f6b3e

Please sign in to comment.