Skip to content

Commit

Permalink
Merge pull request #1577 from messense/fix-1571
Browse files Browse the repository at this point in the history
Fix two sdist issues
  • Loading branch information
messense authored Apr 22, 2023
2 parents 5d5b96a + 7fdc3d5 commit 3807c2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ dunce = "1.0.2"
normpath = "1.0.0"
pep440_rs = { version = "0.3.3", features = ["serde"] }
pep508_rs = { version = "0.1.1", features = ["serde"] }
same-file = "1.0.6"
time = "0.3.17"

# cli
Expand Down
21 changes: 16 additions & 5 deletions src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ fn rewrite_cargo_toml(
manifest_path.display()
))?;

let workspace_deps = workspace_manifest
.get("workspace")
let workspace = workspace_manifest.get("workspace");
let workspace_deps = workspace
.and_then(|x| x.get("dependencies"))
.and_then(|x| x.as_table_like());

Expand Down Expand Up @@ -94,8 +94,7 @@ fn rewrite_cargo_toml(

// Update workspace inherited metadata
if let Some(package) = document.get_mut("package").and_then(|x| x.as_table_mut()) {
let workspace_package = workspace_manifest
.get("workspace")
let workspace_package = workspace
.and_then(|x| x.get("package"))
.and_then(|x| x.as_table_like());
for key in WORKSPACE_INHERITABLE_FIELDS.iter().copied() {
Expand All @@ -111,6 +110,12 @@ fn rewrite_cargo_toml(
}
}
}

// Update resolver if workspace set one
if let Some(resolver) = workspace.and_then(|x| x.get("resolver")) {
package["resolver"] = resolver.clone();
rewritten = true;
}
}

if root_crate {
Expand Down Expand Up @@ -434,7 +439,13 @@ fn add_crate_to_source_distribution(
.any(|(target, _)| target == Path::new("pyproject.toml"))
{
// Add pyproject.toml to the source distribution
if cargo_toml_in_subdir {
// `pyproject.toml` may not be included in `cargo package --list`
// (e.g. it's not specified in `include` or is specified in `exclude` by mistake)
// we check if it's the same pyproject.toml file in Cargo.toml directory
let pyproject_toml_in_manifest_dir =
same_file::is_same_file(pyproject_toml_path, abs_manifest_dir.join("pyproject.toml"))
.unwrap_or(false);
if cargo_toml_in_subdir || pyproject_toml_in_manifest_dir {
// if Cargo.toml is in subdirectory of pyproject.toml directory
target_source.push((
PathBuf::from("pyproject.toml"),
Expand Down

0 comments on commit 3807c2b

Please sign in to comment.