Patch setuptools to remove mandatory config
Review Request #14957 — Created March 24, 2026 and submitted
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 apackage-requirements.txtfile, 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 thepyproject.tomlfile 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 thepyproject.tomlfile itself. This resulting
list then gets set in the internalDistributionobjects 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.
| Summary | ID |
|---|---|
| 6f33cda808411005c4a6dc38b7bb40949e5e5ac1 |
| Description | From | Last Updated |
|---|---|---|
|
RuntimeError might be more appropriate. We don't want this to get optimized out. |
|
- Change Summary:
-
Removed now-unused variables.
- Summary:
-
[WIP] Patch setuptools to remove mandatory configPatch setuptools to remove mandatory config
- Commits:
-
Summary ID cfa7ea412c3d4e5093c3712c34a11ad93f818505 6f33cda808411005c4a6dc38b7bb40949e5e5ac1