python: only link extension modules against libpython when distutils does too. Fixes #4117
python: only link extension modules against libpython when distutils does too. Fixes #4117

Windows requires things to be linked, on macOS distutils doesn't link by default.
On Linux etc. things are not so clear, some distros like Debian patch distutils to not link,
some don't. In addition the manylinux wheels spec prohibits linking against libpython
and upstream is thinking about changing the default:
https://bugs.python.org/issue34814

Call into distutils to figure out what distutils does and in case it doesn't link
against libpython replace the passed in Python dependency with a partial one.

QuLogic/meson,becm/meson,becm/meson,becm/meson,becm/meson,mesonbuild/meson,becm/meson,pexip/meson,pexip/meson,jpakkane/meson,QuLogic/meson,jpakkane/meson,jpakkane/meson,pexip/meson,pexip/meson,pexip/meson,jpakkane/meson,jpakkane/meson,mesonbuild/meson,mesonbuild/meson,mesonbuild/meson,mesonbuild/meson,pexip/meson,pexip/meson,becm/meson,jpakkane/meson,QuLogic/meson,QuLogic/meson,pexip/meson,becm/meson,becm/meson,jpakkane/meson,pexip/meson,mesonbuild/meson,jpakkane/meson,becm/meson,QuLogic/meson,QuLogic/meson,QuLogic/meson,mesonbuild/meson,mesonbuild/meson,QuLogic/meson,mesonbuild/meson,pexip/meson,QuLogic/meson,jpakkane/meson,mesonbuild/meson,becm/meson