Skip to content

Commit 0056182

Browse files
eli-schwartzdnicolodi
authored andcommitted
python module: stop using distutils on sufficiently new python
Disagreement between distutils and sysconfig have been resolved for Python 3.12, see python/cpython#100356 and python/cpython#100967 This is the other half of the fix for mesonbuild#7702.
1 parent 30d3d2e commit 0056182

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mesonbuild/scripts/python_info.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,15 @@ def get_install_paths():
6363
return paths, install_paths
6464

6565
def links_against_libpython():
66-
from distutils.core import Distribution, Extension
67-
cmd = Distribution().get_command_obj('build_ext')
68-
cmd.ensure_finalized()
69-
return bool(cmd.get_libraries(Extension('dummy', [])))
66+
# on versions supporting python-embed.pc, this is the non-embed lib
67+
if sys.version_info >= (3, 12):
68+
variables = sysconfig.get_config_vars()
69+
return bool(variables.get('LIBPYTHON', True))
70+
else:
71+
from distutils.core import Distribution, Extension
72+
cmd = Distribution().get_command_obj('build_ext')
73+
cmd.ensure_finalized()
74+
return bool(cmd.get_libraries(Extension('dummy', [])))
7075

7176
def main():
7277
variables = sysconfig.get_config_vars()

0 commit comments

Comments
 (0)