Skip to content

Commit dfef1a4

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 944fa91 commit dfef1a4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mesonbuild/scripts/python_info.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
del sys.path[0]
1414

1515
import json, os, sysconfig
16-
import distutils.command.install
1716

1817
def get_distutils_paths(scheme=None, prefix=None):
1918
import distutils.dist
@@ -63,10 +62,15 @@ def get_install_paths():
6362
return paths, install_paths
6463

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

7175
def main():
7276
variables = sysconfig.get_config_vars()

0 commit comments

Comments
 (0)