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

Fix two sdist issues #1577

Merged
merged 2 commits into from
Apr 22, 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 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