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 21ab189
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Update MSRV to 1.59.0 in [#1071](https://github.com/PyO3/maturin/pull/1071)
* Fix abi3 wheel build when no Python interpreters found in [#1072](https://github.com/PyO3/maturin/pull/1072)
* Add `zig ar` support in [#1073](https://github.com/PyO3/maturin/pull/1073)
* Fix sdist build for optional path dependencies in [#1084](https://github.com/PyO3/maturin/pull/1084)

## [0.13.2] - 2022-08-14

Expand Down
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 21ab189

Please sign in to comment.