From 00561822554b7d305c2d681a92eab5f06ac0d3b2 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 22 Nov 2022 22:56:10 -0500 Subject: [PATCH] python module: stop using distutils on sufficiently new python Disagreement between distutils and sysconfig have been resolved for Python 3.12, see https://github.com/python/cpython/pull/100356 and https://github.com/python/cpython/pull/100967 This is the other half of the fix for #7702. --- mesonbuild/scripts/python_info.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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()