Follow-up from #31132:
It has been reported that it's still leaking with the upgraded python3 from homebrew that includes Homebrew/homebrew-core@784d292
The sagelib build collects many -I, -L directives through pkgconfig.
Such directives on the command line take precedence over the search paths set by sage-env in $CPATH, $LIBRARY_PATH.
Now if -I/usr/local/ or -L/usr/local (instead of more specific paths to /usr/local/Cellar/.../...) appear, then unwanted packages that happen to be installed can leak in.
However, here the problem is caused by homebrew installing a distutils.cfg that injects /usr/local/include into our include search path.
We fix the leak by switching to a modern configuration of setuptools.
This also affects cysignals, as reported in https://groups.google.com/g/sage-release/c/KdSKg6RdZok/m/91Ibwn8RAgAJ
Relevant tickets: #13348, #14709, #29562 (+), #29607 (+), #29697 (?), #31041 (), #30818 (), #30013 (~); possible follow-up: #31338
CC: @jhpalmieri @zlscherr @kiwifb @kliem @slel
Component: build
Author: Matthias Koeppe
Branch: e03c5ac
Reviewer: John Palmieri
Issue created by migration from https://trac.sagemath.org/ticket/31335