• 
      

    Patch setuptools to remove mandatory config

    Review Request #14957 — Created March 24, 2026 and submitted — Latest diff uploaded

    Information

    buildthings
    master

    Reviewers

    Buildthings injected dependencies into Setuptools through a bit of an
    annoying workaround that we inherited from the in-tree build backends
    for Djblets and Review Board. This required telling Setuptools where to
    find a package-requirements.txt file, which we'd then write to before
    Setuptools got a chance to run, and that it should look up dependencies
    dynamically.

    This change swaps out that hacky workaround for another hacky
    workaround. Instead of making the pyproject.toml file work around
    this, we now do it inside of buildthings.

    When setuptools loads pyproject.toml, it creates a _ConfigExpander
    object that builds a finalized dictionary of settings (factoring in any
    dynamic dependencies or other variables).

    We now hook into this to add mutation functions for the final
    dictionary. We remove any dynamic dependency configuration and then set
    our final list of dependencies for the package. This is equivalent to
    temporarily replacing the pyproject.toml file itself. This resulting
    list then gets set in the internal Distribution objects for the
    package definition.

    While monkey-patching Setuptools is indeed hacky and could break, we are
    at least pinning the version so there are no surprises. Setuptools
    itself is full of patches like this on top of distutils to control
    behavior.

    Tested this on a package with a pre-set list of static dependencies
    and a package with a list of dynamic dependencies. Built both and
    inspected their resulting wheels for the dependencies lists. Verified
    the expected final set of dependencies were present.

    Commits

    Files