--- /dev/null
+#mesondefine PACKAGE
+#mesondefine VERSION
+#mesondefine GST_PACKAGE_NAME
+#mesondefine PACKAGE_NAME
+#mesondefine GST_API_VERSION
+#mesondefine PLUGINDIR
+#mesondefine PY_LIB_LOC
+#mesondefine PY_ABI_FLAGS
+#mesondefine PY_LIB_SUFFIX
+#mesondefine PYTHON_VERSION
--- /dev/null
+subdir('overrides')
--- /dev/null
+pysources = ['Gst.py', 'GstPbutils.py']
+install_data(pysources,
+ install_dir: pygi_override_dir)
+
+gstpython = shared_library('_gi_gst',
+ sources: ['gstmodule.c'],
+ name_prefix: '',
+ name_suffix: py_so_suffix,
+ install: true,
+ install_dir : pygi_override_dir,
+ dependencies : [gst_dep, python_dep, pygobject_dep])
+
+# Workaround to get uninstalled working.
+foreach source: pysources
+ run_command(python, '-c', 'import os; os.symlink("@0@/@1@", "@2@/@3@")'.format(
+ meson.current_source_dir(), source,
+ meson.current_build_dir(), source))
+endforeach
--- /dev/null
+project('gst-python', 'c', 'cpp',
+ version : '1.9.2.1',
+ meson_version : '>= 0.33.0',
+ default_options : [ 'warning_level=1',
+ 'c_std=gnu99',
+ 'buildtype=debugoptimized' ])
+
+gst_version = meson.project_version()
+version_arr = gst_version.split('.')
+gst_version_major = version_arr[0]
+gst_version_minor = version_arr[1]
+api_version = '@0@.0'.format(gst_version_major)
+
+gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
+
+gst_dep = dependency('gstreamer-1.0', version : gst_req,
+ fallback : ['gstreamer', 'gst_dep'])
+gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
+ fallback : ['gstreamer', 'gst_base_dep'])
+gmodule_dep = dependency('gmodule-2.0')
+pygobject_dep = dependency('pygobject-3.0 >= 3.0')
+python_dep = dependency('python3')
+
+python = find_program('python3')
+pythondetector = find_program('pythondetector')
+py_so_suffix = run_command(pythondetector, '--sosuffix').stdout().strip()
+pygi_override_dir = run_command(pythondetector, '--pygi-overridedir').stdout().strip()
+python_abi_flags = run_command(pythondetector, '--abiflags').stdout().strip()
+pylib_loc = run_command(pythondetector, '--libloc').stdout().strip()
+assert(pylib_loc != 'None', 'Python dynamic library path could not be determined')
+
+pylib_suffix = 'so'
+if host_machine.system() == 'windows'
+ pylib_suffix = 'dll'
+elif host_machine.system() == 'darwin'
+ pylib_suffix = 'dylib'
+endif
+
+cdata = configuration_data()
+cdata.set('PACKAGE', '"gst-python"')
+cdata.set('VERSION', '"@0@"'.format(gst_version))
+cdata.set('GST_PACKAGE_NAME', '"GStreamer Python"')
+cdata.set('PACKAGE_NAME', '"GStreamer Python"')
+cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
+cdata.set('PLUGINDIR', '"@0@/gstreamer-1.0"'.format(get_option('libdir')))
+cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
+cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
+cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
+cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
+configure_file(input : 'config.h.meson',
+ output : 'config.h',
+ configuration : cdata)
+configinc = include_directories('.')
+
+subdir('gi')
+subdir('plugin')
--- /dev/null
+gst_elements_shared = shared_library('gstpythonplugin',
+ ['gstpythonplugin.c'],
+ c_args : '-DHAVE_CONFIG_H -DPY_LIB_LOC=@0@'.format(pylib_loc),
+ include_directories : [configinc],
+ dependencies : [gst_dep, pygobject_dep, gstbase_dep, python_dep, gmodule_dep],
+ install : true,
+ install_dir : '@0@/gstreamer-1.0'.format(get_option('libdir')),
+)
--- /dev/null
+#!/usr/bin/env python3
+import os
+import platform
+import subprocess
+import sys
+
+from distutils import sysconfig
+
+
+def get_python_abiflags():
+ try:
+ return subprocess.check_output([os.path.basename(sys.executable) + '-config',
+ '--abiflags']).decode(errors='ignore').strip()
+ except FileNotFoundError:
+ return ''
+
+
+def get_python_libloc():
+ # OSX is a pain. Python as shipped by apple installs libpython in /usr/lib
+ # so we hardcode that. Other systems can use --with-libpython-dir to
+ # override this.
+ if platform.system().lower() == 'darwin':
+ return '/usr/lib'
+
+ python_libs = sysconfig.get_python_lib(standard_lib=1)
+ pylib_loc = python_libs + '/config'
+ pyversion = "%d.%d" % (sys.version_info.major, sys.version_info.minor)
+
+ abiflags = get_python_abiflags()
+ py_sharedlib = pylib_loc + '/libpython' + pyversion + abiflags + '.so'
+ if os.path.exists(os.path.join(py_sharedlib)):
+ return pylib_loc
+
+ pylib_loc = sys.prefix + '/lib64'
+ py_sharedlib = pylib_loc + '/libpython' + pyversion + abiflags + '.so'
+
+ if os.path.exists(os.path.join(py_sharedlib)):
+ return pylib_loc
+
+ pylib_loc = sys.prefix + '/lib'
+ py_sharedlib = pylib_loc + '/libpython' + pyversion + abiflags + '.so'
+ if os.path.exists(os.path.join(py_sharedlib)):
+ return pylib_loc
+
+ pylib_loc = '/usr/lib'
+ py_sharedlib = pylib_loc + '/libpython' + pyversion + abiflags + '.so'
+ if os.path.exists(os.path.join(py_sharedlib)):
+ return pylib_loc
+
+ return "None"
+
+
+if __name__ == "__main__":
+ if len(sys.argv) > 2:
+ print("Only 1 argument accepted")
+ exit(1)
+
+ if sys.argv[1] == '--abiflags':
+ print(get_python_abiflags())
+ elif sys.argv[1] == '--sosuffix':
+ get = sysconfig.get_config_var
+ suffix = get("EXT_SUFFIX") or get("SO") or ".so"
+ print(suffix[1:])
+ elif sys.argv[1] == '--pygi-overridedir':
+ import gi
+ print(gi._overridesdir)
+ elif sys.argv[1] == '--libloc':
+ print(get_python_libloc())