meson: use python.get_install_dir() to find the pygobject overrides dir
authorChristoph Reiter <reiter.christoph@gmail.com>
Sat, 10 Sep 2022 17:16:39 +0000 (19:16 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 12 Sep 2022 00:45:40 +0000 (00:45 +0000)
Instead of trying to hardcode site-packages paths for different platforms
just use python.get_install_dir() from meson and let it deal with the rest.
Also no longer try to import pygobject, which would otherwise not be
required at build time.

python.get_install_dir() was at the beginning broken on Windows, but
that was fixed in 0.60 via https://github.com/mesonbuild/meson/pull/9156
and since ges now requires >0.60 this can be ignored.

This change was motivated by the install path being wrong under MSYS2, where
the unix install layout is used and the detection code not taking that into
account.

This MR is a continuation of https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/230
see the discussion there for extra context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3012>

subprojects/gst-editing-services/meson.build

index 0922435..e45541c 100644 (file)
@@ -278,48 +278,15 @@ if not get_option('examples').disabled()
 endif
 subdir('docs')
 
-override_detector = '''
-import sys
-import os
-
-prefix = sys.argv[1]
-version = sys.version_info
-
-# If we are installing in the same prefix as PyGobject
-# make sure to install in the right place.
-import gi.overrides
-
-overrides_path = os.path.dirname(gi.overrides.__file__)
-if os.path.commonprefix([overrides_path, prefix]) == prefix:
-    print(overrides_path)
-    exit(0)
-
-# Otherwise follow python's way of install site packages inside
-# the provided prefix
-if os.name == 'posix':
-    print(os.path.join(
-        prefix, 'lib', 'python%d.%d' % (version.major, version.minor),
-        'site-packages', 'gi', 'overrides'))
-else:
-    print(os.path.join(
-        prefix, 'Lib', 'Python%d%d' % (version.major, version.minor),
-        'site-packages', 'gi', 'overrides'))
-'''
 pygi_override_dir = get_option('pygi-overrides-dir')
 if pygi_override_dir == ''
-    cres = run_command(python3, '-c', override_detector, get_option('prefix'), check: false)
-    if cres.returncode() == 0
-      pygi_override_dir = cres.stdout().strip()
-    endif
-    if cres.stderr() != ''
-        message(cres.stderr())
-    endif
+  pygi_override_dir = python3.get_install_dir(
+    subdir : join_paths('gi', 'overrides')
+  )
 endif
 
-if pygi_override_dir != ''
-  message('pygobject overrides directory ' + pygi_override_dir)
-  subdir('bindings/python')
-endif
+message('pygobject overrides directory = @0@'.format(pygi_override_dir))
+subdir('bindings/python')
 
 # Set release date
 if gst_version_nano == 0