1#----------------------------------------------------------------------------- 2# Copyright (c) 2005-2019, PyInstaller Development Team. 3# 4# Distributed under the terms of the GNU General Public License with exception 5# for distributing bootloader. 6# 7# The full license is in the file COPYING.txt, distributed with this software. 8#----------------------------------------------------------------------------- 9""" 10Import hook for Gst(GStreamer) http://gstreamer.freedesktop.org/ introspected through 11PyGobject https://wiki.gnome.org/PyGObject via the GObject Introspection middleware 12layer https://wiki.gnome.org/Projects/GObjectIntrospection 13 14Tested with GStreamer 1.4.5, gst-python 1.4.0, PyGObject 3.16.2, and GObject Introspection 1.44.0 on Mac OS X 10.10 and 15GStreamer 1.4.5, gst-python 1.4.0, PyGObject 3.14.0, and GObject Introspection 1.42 on Windows 7 16""" 17 18 19# GStreamer contains a lot of plugins. We need to collect them and bundle them wih the exe file. 20# We also need to resolve binary dependencies of these GStreamer plugins. 21 22 23import glob 24import os 25from PyInstaller.utils.hooks import collect_glib_share_files, collect_glib_translations, exec_statement, get_gi_typelibs 26 27binaries, datas, hiddenimports = get_gi_typelibs('Gst', '1.0') 28 29datas += collect_glib_share_files('gstreamer-1.0') 30 31hiddenimports += ["gi.repository.Gio"] 32 33for prog in ['gst-plugins-bad-1.0', 34 'gst-plugins-base-1.0', 35 'gst-plugins-good-1.0', 36 'gst-plugins-ugly-1.0', 37 'gstreamer-1.0']: 38 datas += collect_glib_translations(prog) 39 40statement = """ 41import os 42import gi 43gi.require_version('Gst', '1.0') 44from gi.repository import Gst 45Gst.init(None) 46reg = Gst.Registry.get() 47plug = reg.find_plugin('coreelements') 48path = plug.get_filename() 49print(os.path.dirname(path)) 50""" 51 52plugin_path = exec_statement(statement) 53 54# Use a pattern of libgst* since all GStreamer plugins that conform to GStreamer standards start with libgst 55# and we may have mixed plugin extensions, e.g., .so and .dylib. 56for pattern in ['libgst*.dll', 'libgst*.dylib', 'libgst*.so']: 57 pattern = os.path.join(plugin_path, pattern) 58 binaries += [(f, os.path.join('gst_plugins')) for f in glob.glob(pattern)] 59