diff --git a/mesonbuild/scripts/python_info.py b/mesonbuild/scripts/python_info.py index 7b3fa8454892..a4bcf55f93ea 100755 --- a/mesonbuild/scripts/python_info.py +++ b/mesonbuild/scripts/python_info.py @@ -63,10 +63,15 @@ def get_install_paths(): return paths, install_paths def links_against_libpython(): - from distutils.core import Distribution, Extension - cmd = Distribution().get_command_obj('build_ext') - cmd.ensure_finalized() - return bool(cmd.get_libraries(Extension('dummy', []))) + # on versions supporting python-embed.pc, this is the non-embed lib + if sys.version_info >= (3, 12): + variables = sysconfig.get_config_vars() + return bool(variables.get('LIBPYTHON', True)) + else: + from distutils.core import Distribution, Extension + cmd = Distribution().get_command_obj('build_ext') + cmd.ensure_finalized() + return bool(cmd.get_libraries(Extension('dummy', []))) def main(): variables = sysconfig.get_config_vars()