macOS: venvs lacking `python3-config` causes some builds to fail
Description
Some more complex C/C++ libraries need python3-config to get ldflags, include directories, etc.
On Linux, because each version of Python is in its own container, this works fine.
On macOS, because cibuildwheel relies entirely on virtualenvs and does not put /Library/Frameworks/Python.framework/Versions/{current_version}/bin in PATH, python3-config defaults to the system-wide Python 3.11/3.12 installation. Meaning any non-trivial C/C++ extensions may fail (and not even outright fail to build- wheels produced may fail to import because of missing symbols due to ABI breaks.)
A fix to this would be to prepend /Library/Frameworks/Python.framework/Versions/{current_version}/bin to PATH during builds.
For users currently blocked by this, a possible workaround is adding this in your CIBW_BEFORE_BUILD:
ln -s $(dirname $(readlink -f $(which python3)))/python3-config $(dirname $(which python3))/python3-config
Build log
https://github.com/donn/cibw_clobber/actions/runs/11091306625/job/30814862405
CI config
https://github.com/donn/cibw_clobber/blob/main/.github/workflows/ci.yml
You should not depend on python3-config being present if you are in Python - instead, you should use sysconfig directly. (Or use a modern build system like scikit-build-core or meson-python).
I wonder, why do the venvs not add this. Seems a little odd. But I'd be open to adding a symlink to our venvs on macOS if others are hitting it.