Skip to content

Clean up internal fields of WheelWriter#2870

Merged
messense merged 2 commits intoPyO3:mainfrom
e-nomem:wheel-writer-cleanup
Nov 24, 2025
Merged

Clean up internal fields of WheelWriter#2870
messense merged 2 commits intoPyO3:mainfrom
e-nomem:wheel-writer-cleanup

Conversation

@e-nomem
Copy link
Copy Markdown
Contributor

@e-nomem e-nomem commented Nov 23, 2025

This PR makes basically 3 changes:

  1. Change the record field in WheelWriter to a BTreeMap so that the records are already sorted by path
  2. Replace ZipWriter::start_file() with ZipWriter::start_file_from_path() because the latter automatically deals with zip path normalization, including replacing back slashes with forward slashes
  3. Remove the record_path and wheel_path fields from the struct because wheel_path can be recovered from the underlying file after the zip is closed, and record_path can be calculated from Metadata24 if provided

@messense messense merged commit d593605 into PyO3:main Nov 24, 2025
45 checks passed
@e-nomem e-nomem deleted the wheel-writer-cleanup branch November 24, 2025 04:00
messense added a commit that referenced this pull request Feb 7, 2026
#2870 refactored `module_writer.rs`, and in doing so [removed a
line](d593605#diff-a5f91562326af952084dcfb75851be91314679f06545de0c7ea8e9057ebe6ad5L55)
which reformatted `PathBuf` rendered platform-specific `String`s to
exclusively us `/`:

```python
// The zip standard mandates using unix style paths
let target = target.to_str().unwrap().replace('\\', "/");
```

While it seems this is [technically
allowed](https://packaging.python.org/en/latest/specifications/recording-installed-packages/#the-record-file),
some tools choke on this. In my case, the
[`wheel`](https://pypi.org/project/wheel/) package does not like
windows-style paths in the `RECORD` file (even on Windows itself).

I've also added a unit test to validate this - though because the
implementation uses `PathBuf::to_string_lossy`, it will only actually
fail on Windows.

---------

Co-authored-by: messense <messense@icloud.com>
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.

2 participants