build: Correctly check for Python modules

Currently using Meson the command "python -m <MODULE_NAME>" is
run. However this command instead of trying to import the module
tried to execute it as a script failing for the updated pyparsing
with:

    /usr/bin/python3: No module named pyparsing.__main__; 'pyparsing' is a package and cannot be directly executed

So instead use "python -c 'import <MODULE_NAME>".
Autoconf is already using that command (see m4/ax_python_module.m4).

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
This commit is contained in:
Frediano Ziglio 2021-10-28 16:45:34 +01:00
parent 96dd787377
commit a7b5474bf8

View File

@ -132,7 +132,7 @@ if spice_common_generate_client_code or spice_common_generate_server_code
if get_option('python-checks')
foreach module : ['six', 'pyparsing']
message('Checking for python module @0@'.format(module))
cmd = run_command(python, '-m', module)
cmd = run_command(python, '-c', 'import @0@'.format(module))
if cmd.returncode() != 0
error('Python module @0@ not found'.format(module))
endif