diff --git a/Changelog.md b/Changelog.md index b5cd431ad..1f9e6630d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Unreleased * Fix adding `project.license-files` to source distributions. +* Fix relative Readme rewrite of the root crate in source distributions. ## [1.9.2] diff --git a/src/source_distribution.rs b/src/source_distribution.rs index 98d331eaf..0dc7a2a50 100644 --- a/src/source_distribution.rs +++ b/src/source_distribution.rs @@ -502,17 +502,8 @@ fn add_cargo_package_files_to_sdist( .unwrap() .strip_prefix(&sdist_root) .unwrap(); - add_crate_to_source_distribution( - writer, - manifest_path, - root_dir.join(relative_main_crate_manifest_dir), - None, - &known_path_deps, - true, - false, - )?; // Handle possible relative readme field in Cargo.toml - if let Some(readme) = main_crate.readme.as_ref() { + let readme_path = if let Some(readme) = main_crate.readme.as_ref() { let readme = abs_manifest_dir.join(readme); let abs_readme = readme .normalize() @@ -531,7 +522,19 @@ fn add_cargo_package_files_to_sdist( .join(readme.file_name().unwrap()), &abs_readme, )?; - } + Some(abs_readme) + } else { + None + }; + add_crate_to_source_distribution( + writer, + manifest_path, + root_dir.join(relative_main_crate_manifest_dir), + readme_path.as_deref(), + &known_path_deps, + true, + false, + )?; // Add Cargo.lock file and workspace Cargo.toml let manifest_cargo_lock_path = abs_manifest_dir.join("Cargo.lock"); diff --git a/tests/run.rs b/tests/run.rs index c093f433a..451605898 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -648,6 +648,7 @@ fn workspace_members_non_local_dep_sdist() { edition = "2021" description = "Implements a dummy function (get_fortytwo.DummyClass.get_42()) in rust" license = "MIT" + readme = "README.md" [dependencies] pyo3 = { version = "0.25.0", features = [