From 8e42b632016ca0eb237721a002de23373cec04ca Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 22 Jan 2019 16:59:02 -0300 Subject: [PATCH] meson: Re add workarounds to detect libpython path This was removed all together in af4ade37435fcc31c8489f4d7c7496fef5f74b05 "meson: use new python module". And add `-Dlibpython-dir` option for the cases the logic fails. --- meson.build | 28 +++++++++++++++++++++++++--- meson_options.txt | 3 ++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 70abfd2c89..239af157e4 100644 --- a/meson.build +++ b/meson.build @@ -27,10 +27,32 @@ python = pymod.find_installation(get_option('python')) python_dep = python.dependency(required : true) 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') +pylib_loc = get_option('libpython-dir') +if pylib_loc == '' + check_path_exists = 'import os, sys; assert(os.path.exists(sys.argv[1]))' + pylib_loc = python.get_variable('LIBPL', '') + if host_machine.system() != 'windows' + pylib_ldlibrary = python.get_variable('LDLIBRARY', '') + if host_machine.system() == 'darwin' + # OSX is a pain. Python as shipped by apple installs libpython in /usr/lib + # so we hardcode that. Other systems can use -Dlibpythondir to + # override this. + pylib_loc = '/usr/lib' + else + if run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() != 0 + # Workaround for Fedora + pylib_loc = python.get_variable('LIBDIR', '') + message('pylib_loc = @0@'.format(pylib_loc)) + endif + endif + + assert( + run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() == 0, + 'Python dynamic library path could not be determined' + ) + endif endif + message('python_abi_flags = @0@'.format(python_abi_flags)) message('pylib_loc = @0@'.format(pylib_loc)) diff --git a/meson_options.txt b/meson_options.txt index 68cf814b74..7074b98222 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,5 @@ 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', value : 'python3')