Fix persistent build/
dir with tox wheels
#1098
Merged
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.
tox build_wheel has been producing a
build/
directory (setuptools)which is not cleared between runs. This manifests as a very bad and
confusing developer experience when a module is renamed or moved, and
both the old and new files are present in the sdist and wheel for
testing. This can result in module name shadowing and other hard to
debug issues.
We have attempted to solve this in the past by means of custom
external packaging environments, but have never found a satisfactory
solution. This new approach is to "bite the bullet" and use tox's
plugin extension points. Via pluggy, tox is providing the same
architecture for extension which pytest is based around, meaning that
the 'toxfile.py' should be thought of as analogous to 'conftest.py'
(already familiar) and the hook decorator should be understood to be
similar to
@pytest.fixture
or definition of hook methods likepytest_configure
.We only define one hook, which is invoked each time
tox
isinstalling into an environment. We inspect the environment name and
abort if it's anything other than
"build_wheel"
. If and only ifwe're running the install phase of
"build_wheel"
, we will remove thebuild/
directory if present.For my final test runs of the new behavior, I ran tox, manually added
files to
build/
, then ran tox again. I was able to confirm that theextra files in
build/
were removed. The same testing procedure failson
main
. I also confirmed thattox p
was not measurably slower,indicating that the build-once semantics are being preserved.
📚 Documentation preview 📚: https://globus-sdk-python--1098.org.readthedocs.build/en/1098/