From 5dcd1f788633a98d77a725e49fcd8dba14e5b856 Mon Sep 17 00:00:00 2001 From: Eashwar Ranganathan Date: Fri, 21 Nov 2025 08:35:15 -0500 Subject: [PATCH 1/2] Emit a warning if a file is excluded from the archive by matching the target --- src/module_writer/sdist_writer.rs | 7 +++++++ src/module_writer/wheel_writer.rs | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/module_writer/sdist_writer.rs b/src/module_writer/sdist_writer.rs index 4aa4bdade..c40588d8a 100644 --- a/src/module_writer/sdist_writer.rs +++ b/src/module_writer/sdist_writer.rs @@ -52,6 +52,13 @@ impl ModuleWriter for SDistWriter { let target = target.as_ref(); if self.exclude(target) { + eprintln!( + "⚠️ Warning: {} was excluded from the archive by the target path in the archive instead of the source path on the filesystem", + target.display(), + ); + eprintln!( + " This behavior is deprecated and will be removed in future versions of maturin" + ); return Ok(()); } diff --git a/src/module_writer/wheel_writer.rs b/src/module_writer/wheel_writer.rs index 674841c94..0305ec8b0 100644 --- a/src/module_writer/wheel_writer.rs +++ b/src/module_writer/wheel_writer.rs @@ -40,8 +40,21 @@ impl ModuleWriter for WheelWriter { mut data: impl Read, executable: bool, ) -> Result<()> { + if let Some(source) = source { + if self.exclude(source) { + return Ok(()); + } + } + let target = target.as_ref(); if self.exclude(target) { + eprintln!( + "⚠️ Warning: {} was excluded from the archive by the target path in the archive instead of the source path on the filesystem", + target.display(), + ); + eprintln!( + " This behavior is deprecated and will be removed in future versions of maturin" + ); return Ok(()); } From b9ed7d821b9c80aa3dc52bc43712f358096468ea Mon Sep 17 00:00:00 2001 From: Eashwar Ranganathan Date: Fri, 28 Nov 2025 12:46:54 -0500 Subject: [PATCH 2/2] Address PR feedback --- src/module_writer/sdist_writer.rs | 19 ++++++++++++------- src/module_writer/wheel_writer.rs | 18 +++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/module_writer/sdist_writer.rs b/src/module_writer/sdist_writer.rs index c40588d8a..b8245194b 100644 --- a/src/module_writer/sdist_writer.rs +++ b/src/module_writer/sdist_writer.rs @@ -10,6 +10,7 @@ use flate2::write::GzEncoder; use fs_err as fs; use ignore::overrides::Override; use normpath::PathExt as _; +use tracing::debug; use crate::Metadata24; @@ -34,6 +35,7 @@ pub struct SDistWriter { file_tracker: FileTracker, excludes: Override, mtime: u64, + target_exclusion_warning_emitted: bool, } impl ModuleWriter for SDistWriter { @@ -52,13 +54,15 @@ impl ModuleWriter for SDistWriter { let target = target.as_ref(); if self.exclude(target) { - eprintln!( - "⚠️ Warning: {} was excluded from the archive by the target path in the archive instead of the source path on the filesystem", - target.display(), - ); - eprintln!( - " This behavior is deprecated and will be removed in future versions of maturin" - ); + if !self.target_exclusion_warning_emitted { + self.target_exclusion_warning_emitted = true; + eprintln!( + "⚠️ Warning: A file was excluded from the archive by the target path in the archive\n\ + ⚠️ instead of the source path on the filesystem. This behavior is deprecated and\n\ + ⚠️ will be removed in future versions of maturin.", + ); + } + debug!("Excluded file {target:?} from archive by target path"); return Ok(()); } @@ -117,6 +121,7 @@ impl SDistWriter { file_tracker: FileTracker::default(), excludes, mtime: mtime_override.unwrap_or(SDIST_DETERMINISTIC_TIMESTAMP), + target_exclusion_warning_emitted: false, }) } diff --git a/src/module_writer/wheel_writer.rs b/src/module_writer/wheel_writer.rs index 0305ec8b0..fc92443fc 100644 --- a/src/module_writer/wheel_writer.rs +++ b/src/module_writer/wheel_writer.rs @@ -30,6 +30,7 @@ pub struct WheelWriter { file_tracker: FileTracker, excludes: Override, file_options: SimpleFileOptions, + target_exclusion_warning_emitted: bool, } impl ModuleWriter for WheelWriter { @@ -48,13 +49,15 @@ impl ModuleWriter for WheelWriter { let target = target.as_ref(); if self.exclude(target) { - eprintln!( - "⚠️ Warning: {} was excluded from the archive by the target path in the archive instead of the source path on the filesystem", - target.display(), - ); - eprintln!( - " This behavior is deprecated and will be removed in future versions of maturin" - ); + if !self.target_exclusion_warning_emitted { + self.target_exclusion_warning_emitted = true; + eprintln!( + "⚠️ Warning: A file was excluded from the archive by the target path in the archive\n\ + ⚠️ instead of the source path on the filesystem. This behavior is deprecated and\n\ + ⚠️ will be removed in future versions of maturin.", + ); + } + debug!("Excluded file {target:?} from archive by target path"); return Ok(()); } @@ -107,6 +110,7 @@ impl WheelWriter { file_tracker: FileTracker::default(), excludes, file_options, + target_exclusion_warning_emitted: false, }; write_dist_info(&mut builder, pyproject_dir, metadata24, tags)?;