python_opt = get_option('with-python') if python_opt.startswith('python3') # Python 3.8 introduced a new -embed variant if not python_opt.endswith('-embed') python_dep = dependency(python_opt + '-embed', version: '>= 3.3', required: false) if not python_dep.found() python_dep = dependency(python_opt, version: '>= 3.3') endif else python_dep = dependency(python_opt, version: '>= 3.3') endif else python_dep = dependency(python_opt, version: '>= 2.7') endif python_py_conf = configuration_data() python_py_conf.set('VERSION', meson.project_version()) python_py = configure_file( input: 'python.py', output: 'python.py', configuration: python_py_conf ) python3_source = custom_target('python-bindings', input: ['../../src/common/zoitechat-plugin.h', python_py], output: 'python.c', command: [find_program('generate_plugin.py'), '@INPUT@', '@OUTPUT@'] ) # Include any selected additive API modules alongside the compatibility modules. python_api_files = run_command(python3, '-c', 'import glob,sys; print("\\n".join(sorted(glob.glob(sys.argv[1] + "/_zoitechat*.py"))))', meson.current_source_dir(), check: true).stdout().strip().split('\n') install_data(python_api_files + ['zoitechat.py', 'xchat.py', 'hexchat.py'], install_dir: join_paths(get_option('libdir'), 'zoitechat/python') ) shared_module('python', python3_source, dependencies: [zoitechat_plugin_dep, python_dep], install: true, install_dir: plugindir, name_prefix: '', vs_module_defs: 'python.def' )