From dfef1a47cd74a5cc8bed903a6df2b2e67e10f53c 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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mesonbuild/scripts/python_info.py b/mesonbuild/scripts/python_info.py index cfa2b1dd86da..3fb07fb53cab 100755 --- a/mesonbuild/scripts/python_info.py +++ b/mesonbuild/scripts/python_info.py @@ -13,7 +13,6 @@ del sys.path[0] import json, os, sysconfig -import distutils.command.install def get_distutils_paths(scheme=None, prefix=None): import distutils.dist @@ -63,10 +62,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()