• 
      

    Fix dependency patching when run across multiple PEP 517 hooks.

    Review Request #15028 — Created May 7, 2026 and submitted — Latest diff uploaded

    Information

    buildthings
    master

    Reviewers

    Since switching to the buildthings backend, running tox in djblets was
    crashing with an assertion "Attempted to patch dependencies too late!"

    The cause here is that pyproject_api invokes build hooks multiple times
    in a single worker process, so the earlier get_requires_for_build_*
    hooks instantiate a _ConfigExpander (via Distribution) before
    prepare_metadata_for_build_wheel calls
    patch_setuptools_package_deps(). The "already initialized" assertion
    fired in that case, even though the next _ConfigExpander instance (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
      tox successfully.
    • Ran unit tests.

    Commits

    Files