Emit a warning if a file is excluded from the archive by matching the target#2874
Emit a warning if a file is excluded from the archive by matching the target#2874
Conversation
fa60681 to
c59bc46
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements a deprecation warning for files excluded from archives by matching the target path instead of the source path on the filesystem, as proposed in issue #2867. The implementation helps users identify when their exclude patterns are matching archive paths rather than source paths, preparing them for a future breaking change.
Key Changes:
- Added early exclusion check for source paths before processing (wheel_writer.rs and sdist_writer.rs)
- Emits deprecation warnings when files are excluded by target path matching
- Ensures files excluded by source path return silently without warnings
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/module_writer/wheel_writer.rs | Added source path exclusion check and deprecation warning for target path exclusion in wheel archives |
| src/module_writer/sdist_writer.rs | Added source path exclusion check and deprecation warning for target path exclusion in source distributions |
| 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" | ||
| ); |
There was a problem hiding this comment.
This warning message is duplicated in sdist_writer.rs (lines 55-61). Consider extracting it to a shared function or constant to maintain consistency and reduce duplication. For example:
// In mod.rs or a util module
fn warn_target_path_exclusion(target: &Path) {
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"
);
}Then call it from both WheelWriter::add_bytes and SDistWriter::add_bytes.
There was a problem hiding this comment.
I'm not a huge fan of the duplicate code but, if you don't mind it for the moment, I do have a plan to extract the file tracking and exclusion logic out of the wheel and sdist writers into a 'virtual' writer layer (the reason for this is unrelated to file exclusions but it happens to be a useful side-effect). That code isn't ready for review yet but if you're curious you can see it here: https://github.com/e-nomem/maturin/tree/virtual-writer
c59bc46 to
ebef346
Compare
ebef346 to
b9ed7d8
Compare
This implements the proposal in #2867