diff options
author | Havard Graff <havard.graff@gmail.com> | 2018-05-14 10:05:15 +0200 |
---|---|---|
committer | Mathieu Duponchelle <mathieu@centricular.com> | 2018-10-28 17:53:44 +0100 |
commit | af4ade37435fcc31c8489f4d7c7496fef5f74b05 (patch) | |
tree | b55aaf913ec6b5e644d69b5fd29e0167a5e42c21 /meson.build | |
parent | a15ed715f05be873b6c299ccdf5ee911e0acd956 (diff) |
meson: use new python module
This patch makes the tests pass running uninstalled and installed, with
python2 and python3 on linux, windows and osx.
The main gist is to use the new python-module to do the lifting done
by pythondetector, and with that add support for python2 and windows.
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/meson.build b/meson.build index 1ef0de1..00898f8 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,8 @@ gst_version_major = version_arr[0] gst_version_minor = version_arr[1] api_version = '@0@.0'.format(gst_version_major) +add_project_arguments('-DHAVE_CONFIG_H', language: 'c') + gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor) gst_dep = dependency('gstreamer-1.0', version : gst_req, @@ -21,32 +23,32 @@ gmodule_dep = dependency('gmodule-2.0') pygobject_dep = dependency('pygobject-3.0', fallback: ['pygobject', 'pygobject_dep'], version : '>= 3.8') python_dep = dependency('python3') -python3 = import('python3').find_python() -pythondetector = find_program('scripts/pythondetector') - -cres = run_command(pythondetector, '--sosuffix') -if cres.returncode() != 0 - error('Could not detect python sosuffix' + cres.stdout() + cres.stderr()) -endif -py_so_suffix = cres.stdout().strip() - -cres = run_command(pythondetector, '--abiflags') -if cres.returncode() != 0 - error('Could not detect python abiflags' + cres.stdout() + cres.stderr()) -endif -python_abi_flags = cres.stdout().strip() +pymod = import('python') +python = pymod.find_installation(get_option('python')) +python_dep = python.dependency(required : true) -cres = run_command(pythondetector, '--libloc') -if cres.returncode() != 0 - error('Could not detect python library location' + cres.stdout() + cres.stderr()) +python_abi_flags = python.get_variable('ABIFLAGS', '') +pylib_loc = python.get_variable('LIBPL', '') +if host_machine.system() != 'windows' + assert(pylib_loc != '', 'Python dynamic library path could not be determined') endif -pylib_loc = cres.stdout().strip() +message('python_abi_flags = @0@'.format(python_abi_flags)) +message('pylib_loc = @0@'.format(pylib_loc)) -assert(pylib_loc != 'None', 'Python dynamic library path could not be determined') pygi_override_dir = get_option('pygi-overrides-dir') if pygi_override_dir == '' - cres = run_command(pythondetector, '--pygi-overridedir', - get_option('prefix')) + cres = run_command(python, '-c',''' +import os, sys, gi.overrides +paths = gi.overrides.__path__ +prefix = os.path.abspath(sys.argv[1]) +for path in paths: + path = os.path.abspath(path) + if os.path.commonprefix([path, prefix]) == prefix: + print(path) + exit(0) +exit(1) +''', get_option('prefix')) + if cres.returncode() != 0 error('Could not detect PyGObject overrides location' + cres.stdout() + cres.stderr()) endif @@ -55,7 +57,7 @@ if pygi_override_dir == '' message(cres.stderr()) endif endif -message('pygobject overrides directory ' + pygi_override_dir) +message('pygobject overrides directory = @0@'.format(pygi_override_dir)) pylib_suffix = 'so' if host_machine.system() == 'windows' @@ -81,4 +83,4 @@ subdir('gi') subdir('plugin') subdir('testsuite') -run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")') +run_command(python, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")') |