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 30d3d2e commit 0056182
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mesonbuild/scripts/python_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0056182

Please sign in to comment.