Skip to content

Commit

Permalink
python module: stop using distutils on sufficiently new python
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eli-schwartz authored and dnicolodi committed Sep 8, 2023
1 parent 9115145 commit 5403061
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mesonbuild/scripts/python_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5403061

Please sign in to comment.