Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't package dev-only path dependencies in sdist #1435

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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