Fix dependency patching when run across multiple PEP 517 hooks.
Review Request #15028 — Created May 7, 2026 and submitted — Latest diff uploaded
Since switching to the buildthings backend, running
toxin djblets was
crashing with an assertion "Attempted to patch dependencies too late!"The cause here is that
pyproject_apiinvokes build hooks multiple times
in a single worker process, so the earlierget_requires_for_build_*
hooks instantiate a_ConfigExpander(viaDistribution) before
prepare_metadata_for_build_wheelcalls
patch_setuptools_package_deps(). The "already initialized" assertion
fired in that case, even though the next_ConfigExpanderinstance (the
one we actually want to patch) has not been built yet.This change gets rid of the assertion, and clears the post-funcs list
before appending so deps don't stack across hook calls in the same
worker.
- Built a package and put it in my
$PIP_FIND_LINKS. Was able to run
toxsuccessfully. - Ran unit tests.