fix: wheel corruption when running parallel tox processes #3667
+4
−12
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.
When running multiple tox processes in parallel (e.g.,
tox -p autoor multiple CI jobs), users encounter wheel corruption errors:Root Cause
The session view mechanism used hard links (
os.link()) to create per-session copies of built wheels. Hard links share the same underlying file data (inode).Example of the problem:
.tox/.tmp/package/1/pkg-1.0.whl(hard link to original)Even though numbered directories (
.tmp/package/1/,.tmp/package/2/) prevent path collisions, all hard links point to the same inode, so modifying the original corrupts all views.Solution
Replace
os.link()withshutil.copyfile(), which creates an independent copy. On modern copy-on-write filesystems (APFS, Btrfs, XFS with reflink), this automatically uses reflink, making it nearly as fast as hard linking while maintaining data independence.