Skip to content

Avoid copying a cached fallback wheel onto itself - #241

Open
harbinresearcher wants to merge 1 commit into
pypa:mainfrom
harbinresearcher:codex/reuse-wheel-in-place
Open

harbinresearcher wants to merge 1 commit into
pypa:mainfrom
harbinresearcher:codex/reuse-wheel-in-place

Conversation

@harbinresearcher

Copy link
Copy Markdown

Closes #240.

When the metadata fallback builds a wheel in the directory later passed to build_wheel() or build_editable(), cached-wheel reuse copies the wheel onto itself. The subprocess fails even though the requested wheel is already present.

Skip the cached-wheel copy when the existing destination is the same file. Separate output directories retain the existing copy behavior. No backend hook or public API changes.

Four regression cases exercise wheel/editable fallbacks with same/separate directories. A trailing marker verifies the cached wheel is preserved rather than rebuilt. On unmodified main, the two same-directory cases fail and the separate-directory cases pass.

Validation:

  • Linux Python 3.12: baseline 42 passed; patched 46 passed.
  • Windows Python 3.8 and 3.12: baseline 41 passed / 1 failed; patched 45 passed / the same 1 failed. The pre-existing failure is test_path_pollution_symlinked_in_process because this local process lacks symlink privileges (WinError 1314); the new regressions pass on both versions.
  • Pinned pre-commit hooks: all passed, including Ruff, Black and mypy.
  • Strict Sphinx documentation build: passed.
  • Source distribution and wheel built from that source distribution: passed.

Prepared with AI assistance, including tests and local validation. No maintainer approval or production usage is claimed.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked the two fallback build paths with the metadata and wheel directories both shared and separate. The new samefile guard skips an invalid self-copy only for the shared directory, while the normal copy still produces the cached wheel in a distinct output directory. All four focused cases pass, and this matches the reproduction in #240.

This branch has not been deployed

No deployments
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.

Cached wheel reuse fails when the build and metadata fallback share an output directory

2 participants