From 41b779e57cd04e66f79e696508cc0f420fd10957 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Wed, 22 Jan 2025 10:44:33 -0300 Subject: [PATCH] meson: Add python-exe option to override target Python installation Fixes #4185 Part-of: --- meson_options.txt | 1 + subprojects/gst-editing-services/meson.build | 2 +- subprojects/gst-editing-services/meson_options.txt | 2 ++ subprojects/gst-python/meson.build | 2 +- subprojects/gst-python/meson_options.txt | 4 +++- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 64ecc93e4d..d73d9cce34 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -12,6 +12,7 @@ option('vaapi', type : 'feature', value : 'disabled') option('gst-examples', type : 'feature', value : 'auto', description : 'Build gst-examples subproject') # Bindings option('python', type : 'feature', value : 'auto') +option('python-exe', type: 'string', value: 'python3', description: 'Path or name of the Python interpreter to build for') option('sharp', type : 'feature', value : 'disabled') # External subprojects option('tls', type : 'feature', value : 'auto', description : 'TLS support using glib-networking as a subproject') diff --git a/subprojects/gst-editing-services/meson.build b/subprojects/gst-editing-services/meson.build index 6b2638e70c..d7ed1743d5 100644 --- a/subprojects/gst-editing-services/meson.build +++ b/subprojects/gst-editing-services/meson.build @@ -147,7 +147,7 @@ gir_init_section = [ '--add-init-section=' + \ pymod = import('python') python_opt = get_option('python') -python = pymod.find_installation(required: python_opt) +python = pymod.find_installation(get_option('python-exe'), required: python_opt) has_python = false static_build = get_option('default_library') == 'static' if static_build diff --git a/subprojects/gst-editing-services/meson_options.txt b/subprojects/gst-editing-services/meson_options.txt index f197119b90..ea6b49607a 100644 --- a/subprojects/gst-editing-services/meson_options.txt +++ b/subprojects/gst-editing-services/meson_options.txt @@ -19,6 +19,8 @@ option('xptv', type : 'feature', value : 'auto', description : 'Build the deprecated xptv formatter') option('python', type : 'feature', value : 'auto', yield: true, description: 'Enable python formatters.') +option('python-exe', type : 'string', value: 'python3', yield: true, + description: 'Path or name of the Python interpreter to build for.') option('libpython-dir', type : 'string', value : '', description: 'Path to find libpythonXX.so') option('validate', type : 'feature', value : 'auto', yield: true, diff --git a/subprojects/gst-python/meson.build b/subprojects/gst-python/meson.build index 4f10371327..7e90476a9a 100644 --- a/subprojects/gst-python/meson.build +++ b/subprojects/gst-python/meson.build @@ -27,7 +27,7 @@ libdl = cc.find_library('dl', required: false) pygobject_dep = dependency('pygobject-3.0', fallback: ['pygobject', 'pygobject_dep'], version : '>= 3.8') pymod = import('python') -python = pymod.find_installation(get_option('python')) +python = pymod.find_installation(get_option('python-exe'), required: true) pythonver = python.language_version() if pythonver.version_compare('<3.0') error('Python2 is not supported anymore, please port your code to python3 (@0@ specified)'.format(python.language_version())) diff --git a/subprojects/gst-python/meson_options.txt b/subprojects/gst-python/meson_options.txt index 0a48d75daf..ef5b7359cb 100644 --- a/subprojects/gst-python/meson_options.txt +++ b/subprojects/gst-python/meson_options.txt @@ -2,6 +2,8 @@ option('pygi-overrides-dir', type : 'string', value : '', description: 'Path to pygobject overrides directory') option('libpython-dir', type : 'string', value : '', description: 'Path to find libpythonXX.so') -option('python', type : 'string') +option('python', type : 'string', deprecated: 'python-exe') +option('python-exe', type : 'string', value : 'python3', yield: true, + description: 'Path or name of the Python interpreter to build for.') option('tests', type : 'feature', value : 'auto', yield : true) option('plugin', type : 'feature', value : 'auto')