Skip to content

Commit

Permalink
Merge #1435
Browse files Browse the repository at this point in the history
1435: Don't package dev-only path dependencies in sdist r=konstin a=messense

When building from sdist, `cargo` only needs `dependencies` and `build-dependencies`, removing `dev-dependencies` entirely from `Cargo.toml` makes sdist size smaller and avoid some problems with dev-only path deps like #1083 (comment).

Co-authored-by: messense <messense@icloud.com>
  • Loading branch information
bors[bot] and messense authored Jan 30, 2023
2 parents 2d5998b + 0f64240 commit 7b19fa0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add Cargo compile targets configuration for filtering multiple bin targets in [#1339](https://github.com/PyO3/maturin/pull/1339)
* Respect `rustflags` settings in cargo configuration file in [#1405](https://github.com/PyO3/maturin/pull/1405)
* Bump MSRV to 1.63.0 in [#1407](https://github.com/PyO3/maturin/pull/1407)
* Don't package dev-only path dependencies in sdist in [#1435](https://github.com/PyO3/maturin/pull/1435)

## [0.14.10] - 2023-01-13

Expand Down
16 changes: 15 additions & 1 deletion src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ fn rewrite_cargo_toml(
// some_path_dep = { path = "../some_path_dep" }
// ^^^^^^^^^^^^^^^^^^ table[&dep_name]["path"]
// ^^^^^^^^^^^^^ dep_name
for dep_category in &["dependencies", "dev-dependencies", "build-dependencies"] {
for dep_category in ["dependencies", "dev-dependencies", "build-dependencies"] {
if let Some(table) = data.get_mut(dep_category).and_then(|x| x.as_table_mut()) {
if dep_category == "dev-dependencies" {
// Remove dev-dependencies since building from sdist doesn't need them
data.remove(dep_category);
rewritten = true;
continue;
}
let workspace_deps = workspace_manifest
.get("workspace")
.and_then(|x| x.get("dependencies"))
Expand Down Expand Up @@ -477,6 +483,14 @@ fn find_path_deps(cargo_metadata: &Metadata) -> Result<HashMap<String, PathBuf>>
while let Some(top) = stack.pop() {
for dependency in &top.dependencies {
if let Some(path) = &dependency.path {
if matches!(dependency.kind, cargo_metadata::DependencyKind::Development) {
// Skip dev-only dependency
debug!(
"Skipping development only dependency {} ({})",
dependency.name, path
);
continue;
}
// we search for the respective package by `manifest_path`, there seems
// to be no way to query the dependency graph given `dependency`
let dep_manifest_path = path.join("Cargo.toml");
Expand Down

0 comments on commit 7b19fa0

Please sign in to comment.