BLD: fix build error for PyPy on macOS (#26536)
- [x] closes #26536
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

This change should have no effect on CPython, and may fix a crash in when trying to install using PyPy (see #26536).

I've given this a very quick check by installing locally with `pip install -e` (cpython 3.6 on mac). I dont have an easy way to check it on PyPy, so Im hoping the OP from #26536 can do this (@bhy)