meson: import python module

- Use import to find Python installation.
- Run macos-sdk-version.py with Python provided by meson.

This fixes an error when meson and python-packaging are installed from
Homebrew. Currently, the Python executable from python@3.12 is installed as
python3.12 so python3 is referring to system installation, which may not
have packaging module. meson can provide the correct executable via import.
This commit is contained in:
m154k1 2023-10-28 12:16:44 +03:00 committed by Dudemanguy
parent e76660cc54
commit a57bd8e2b8
1 changed files with 5 additions and 2 deletions

View File

@ -13,7 +13,7 @@ project('mpv',
build_root = meson.project_build_root()
source_root = meson.project_source_root()
python = find_program('python3')
python = import('python').find_installation()
# ffmpeg
libavcodec = dependency('libavcodec', version: '>= 58.134.100')
@ -1475,7 +1475,10 @@ endif
macos_sdk_path = ''
macos_sdk_version = '0.0'
if darwin and macos_sdk_version_py.found()
macos_sdk_info = run_command(macos_sdk_version_py, check: true).stdout().split(',')
# Execute macos-sdk-version.py with Python provided by meson.
# In some cases, Python executable with the necessary modules might not refer to python3
# (e.g. python@3.12 and python-packaging Homebrew packages).
macos_sdk_info = run_command(python, macos_sdk_version_py, check: true).stdout().split(',')
macos_sdk_path = macos_sdk_info[0].strip()
macos_sdk_version = macos_sdk_info[1]
endif