Fix compiled artifacts being excluded by source path matching#2910
Merged
Conversation
Member
Author
|
cc @e-nomem |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where compiled shared libraries were incorrectly excluded from wheels when projects used exclude patterns like exclude = ["target/**/*"] to ignore the Cargo target directory. The fix introduces a new add_file_force() method that bypasses exclusion checks for build artifacts.
- Adds
add_file_force()method toVirtualWriterthat directly inserts files into the tracker without exclusion checks - Updates compiled artifact handling to use the new forced-add method
- Removes unused
ModuleWriterimport frombuild_context.rs
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/module_writer/virtual_writer.rs | Adds new add_file_force() method that bypasses exclusion checks for build artifacts |
| src/build_context.rs | Updates external shared library installation to use add_file_force() and removes unused import |
| src/binding_generator/mod.rs | Updates compiled artifact installation to use add_file_force() |
e-nomem
reviewed
Dec 30, 2025
faf7a13 to
41daffc
Compare
The VirtualWriter introduced in d6d23cf checks source paths against exclude patterns, which caused compiled shared libraries to be excluded when projects have patterns like `exclude = ["target/**/*"]` to ignore the Cargo target directory. Add `add_file_force()` method to VirtualWriter that bypasses exclusion checks, and use it for compiled artifacts and external shared libraries which should always be included in the wheel. Fixes builds for projects like cryptography that exclude target/**/*.
41daffc to
f04de5c
Compare
hswong3i
added a commit
to alvistack/PyO3-maturin
that referenced
this pull request
Jan 2, 2026
git clean -xdf
mkdir -p .cargo
cargo vendor > .cargo/config.toml
tar zcvf ../python-maturin_1.11.0.orig.tar.gz --exclude=.git .
debuild -uc -us
cp python-maturin.spec ../python-maturin_1.11.0-1.spec
cp ../python*-maturin*1.11.0*.{gz,xz,spec,dsc} /osc/home\:alvistack/PyO3-maturin-1.11.0/
rm -rf ../python*-maturin*1.11.0*.*
See PyO3#2910
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
hswong3i
added a commit
to alvistack/PyO3-maturin
that referenced
this pull request
Jan 6, 2026
git clean -xdf
mkdir -p .cargo
cargo vendor > .cargo/config.toml
tar zcvf ../python-maturin_1.11.0.orig.tar.gz --exclude=.git .
debuild -uc -us
cp python-maturin.spec ../python-maturin_1.11.0-1.spec
cp ../python*-maturin*1.11.0*.{gz,xz,spec,dsc} /osc/home\:alvistack/PyO3-maturin-1.11.0/
rm -rf ../python*-maturin*1.11.0*.*
See PyO3#2910
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
bmwiedemann
pushed a commit
to bmwiedemann/openSUSE
that referenced
this pull request
Jan 8, 2026
https://build.opensuse.org/request/show/1325799 by user mia + anag_factory - Update to version 1.11.2 (version bump only) - Changes in 1.11.1: * Fix compiled artifacts being excluded by source path matching gh#PyO3/maturin#2910 * Better error reporting for missing interpreters gh#PyO3/maturin#2918 * Ignore unreadable excluded directories gh#PyO3/maturin#2916 - Changes in 1.11.0: * Correct tagging for x86_64 iOS simulator wheels. gh#PyO3/maturin#2851 * Bump MSRV to 1.85.0 and use Rust 2024 edition gh#PyO3/maturin#2850 * Upgrade goblin to 0.10 gh#PyO3/maturin#2853 * Set entry type when adding to the tar file gh#PyO3/maturin#2859 * Split up module_writer.rs code for code organization gh#PyO3/maturin#2857 * Update environment variables for Android cross-compilation support gh#PyO3/maturin#2825 * Upgrade some
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The VirtualWriter introduced in d6d23cf checks source paths against exclude patterns, which caused compiled shared libraries to be excluded when projects have patterns like
exclude = ["target/**/*"]to ignore the Cargo target directory.Add
add_file_force()method to VirtualWriter that bypasses exclusion checks, and use it for compiled artifacts and external shared libraries which should always be included in the wheel.Fixes #2909