Split up module_writer.rs code for code organization#2857
Merged
Split up module_writer.rs code for code organization#2857
Conversation
5f714b3 to
2cc1a45
Compare
2cc1a45 to
6db1555
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR reorganizes the large module_writer.rs file by splitting it into multiple smaller, more manageable files without changing any logic. The refactoring creates a new module structure with module_writer and binding_generator directories, each containing focused submodules.
Key changes:
- Splits
module_writer.rs(1561 lines) into separate modules:wheel_writer.rs,sdist_writer.rs,path_writer.rs, andutil.rs - Creates new
binding_generatormodule with submodules for different binding types (pyo3, cffi, uniffi, wasm) - Refactors
FileTrackerfrom a tuple struct to a struct with a namedfilesfield - Adjusts visibility modifiers to accommodate the new module structure
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/module_writer.rs | Deleted the original 1561-line file |
| src/module_writer/mod.rs | New module root with common traits and functions |
| src/module_writer/wheel_writer.rs | Extracted WheelWriter implementation |
| src/module_writer/sdist_writer.rs | Extracted SDistWriter implementation |
| src/module_writer/path_writer.rs | Extracted PathWriter implementation |
| src/module_writer/util.rs | Extracted FileTracker utility |
| src/binding_generator/mod.rs | New module for binding generation |
| src/binding_generator/pyo3_binding.rs | Extracted PyO3 binding logic |
| src/binding_generator/cffi_binding.rs | Extracted CFFI binding logic |
| src/binding_generator/uniffi_binding.rs | Extracted UniFfi binding logic |
| src/binding_generator/wasm_binding.rs | Extracted WASM binding logic |
| src/compression.rs | Moved get_file_options method here |
| src/build_context.rs | Updated imports for new module structure |
| src/lib.rs | Added binding_generator module |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
messense
approved these changes
Nov 19, 2025
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.
I was going to refactor the
write_<binding>_module()methods because it seems like there's a lot of duplicate logic in those functions, but themodule_writer.rsfile is absolutely massive and annoying to navigate. Instead, I made this PR which contains absolutely no logic changes, and just copy/pastes the code into multiple smaller files for code organization.The only changes here are occasionally to the visibility of the structs and functions to accommodate the new module structure.