fix(tests): build packaging-test wheels from a private source copy - #130
Merged
Merged
Conversation
tests/test_packaging.py ran `python -m build` in the repo root from every
test. setuptools stages builds in build/ and *.egg-info inside the source
tree, so under pytest-xdist parallel builds deleted each other's staging
directory mid-build:
error: [Errno 2] No such file or directory: 'build/bdist.linux-x86_64/wheel'
_build_wheel now copies the checkout (minus .git, build/dist droppings,
caches, *.sif and the local .plans symlink) into the test's tmp_path and
builds there. tests/ is kept in the copy so the "tests are not shipped"
check still has something to exclude.
Reproduced first: 4/4 runs of `pytest -n 5 tests/test_packaging.py` had a
failure. After the fix: 0/4, and the file passes serially.
Contributions:
- Claude (Opus 5.5): code edits, review, and conceptual discussion
- Jonathan Schultz: overall vision, planning, review, and orchestration
Co-authored-by: Jonathan Schultz <nccu-schultz-lab@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes the flaky wheel-build tests in
tests/test_packaging.py, first noted in #129.Root cause: every test ran
python -m buildin the repository root. setuptools writes its intermediate build files intobuild/and*.egg-infoin the source tree, so when pytest-xdist runs several of these tests at once, one build deletes the directory another build is still using:Fix:
_build_wheelnow copies the checkout into the test'stmp_pathand builds from that copy, so every test has its own build directories..git, oldbuild/dist/*.egg-infooutput, cache folders,*.sifcontainer images, and the local.planssymlink.tests/stays in the copy, so the "tests are not shipped" check still has atests/package to exclude.This is a test-only change.
Testing
pytest -n 5 tests/test_packaging.pyfailed in 4 of 4 runs, on various tests. I also reproduced thebuild/bdisterror directly by running fourpython -m buildprocesses at the same time.-n 5, and the file passes when run serially (-n0).pre-commit runis clean.Authorship
🤖 Generated with Claude Code
Generated by Claude Code