Skip to content

Fix compiled artifacts being excluded by source path matching#2910

Merged
messense merged 1 commit into
PyO3:mainfrom
messense:add-file-force
Dec 31, 2025
Merged

Fix compiled artifacts being excluded by source path matching#2910
messense merged 1 commit into
PyO3:mainfrom
messense:add-file-force

Conversation

@messense

Copy link
Copy Markdown
Member

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

Copilot AI review requested due to automatic review settings December 30, 2025 15:05
@messense

Copy link
Copy Markdown
Member Author

cc @e-nomem

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to VirtualWriter that directly inserts files into the tracker without exclusion checks
  • Updates compiled artifact handling to use the new forced-add method
  • Removes unused ModuleWriter import from build_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()

Comment thread src/module_writer/virtual_writer.rs Outdated
Comment thread src/module_writer/virtual_writer.rs
Comment thread src/binding_generator/mod.rs
Comment thread src/module_writer/virtual_writer.rs Outdated
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/**/*.

@e-nomem e-nomem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@messense messense merged commit 570e6ff into PyO3:main Dec 31, 2025
45 checks passed
@messense messense deleted the add-file-force branch December 31, 2025 01:07
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in v1.11.0: editable installs don't seem to install .so

3 participants