Repository: kivy/kivy

Issue:
Kivy 1.11.0 and PyInstaller
### Versions

* Python: 3.6.5
* OS: OSx
* Kivy: 1.11.0
* Kivy installation method: pip

### Description

Kivy pyinstaller hook script fails, please see traceback below:

### Logs

```
$ python3 -m kivy.tools.packaging.pyinstaller_hooks hook ./kivy-hooks
[INFO   ] [Logger      ] Record log in /Users/xxx/.kivy/logs/kivy_19-06-03_16.txt
[INFO   ] [Kivy        ] v1.11.0
[INFO   ] [Kivy        ] Installed at "/usr/local/lib/python3.6/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.6.5 (default, May  7 2018, 14:48:21) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]
[INFO   ] [Python      ] Interpreter at "/usr/local/opt/python/bin/python3.6"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Logger      ] Record log in /Users/xxx/.kivy/logs/kivy_19-06-03_17.txt
[INFO   ] [Kivy        ] v1.11.0
[INFO   ] [Kivy        ] Installed at "/usr/local/lib/python3.6/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.6.5 (default, May  7 2018, 14:48:21) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]
[INFO   ] [Python      ] Interpreter at "/usr/local/opt/python/bin/python3.6"
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
 Traceback (most recent call last):
   File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
     "__main__", mod_spec)
   File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
     exec(code, run_globals)
   File "/usr/local/lib/python3.6/site-packages/kivy/tools/packaging/pyinstaller_hooks/__main__.py", line 11, in <module>
     lines = get_deps_all()['hiddenimports']
   File "/usr/local/lib/python3.6/site-packages/kivy/tools/packaging/pyinstaller_hooks/__init__.py", line 275, in get_deps_all
     'binaries': _find_gst_binaries(),
   File "/usr/local/lib/python3.6/site-packages/kivy/tools/packaging/pyinstaller_hooks/__init__.py", line 354, in _find_gst_binaries
     gst_plugin_path = _find_gst_plugin_path()
   File "/usr/local/lib/python3.6/site-packages/kivy/tools/packaging/pyinstaller_hooks/__init__.py", line 342, in _find_gst_plugin_path
     match = re.search(r'\s+(\S+libgstcoreelements\.\S+)', stdoutdata)
   File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 182, in search
     return _compile(pattern, flags).search(string)
 TypeError: cannot use a string pattern on a bytes-like object
```



Discussion:
This is caused by https://github.com/kivy/kivy/pull/6165. I'm guessing it was only tested on py2.

Resolving patch:
diff --git a/kivy/tools/packaging/pyinstaller_hooks/__init__.py b/kivy/tools/packaging/pyinstaller_hooks/__init__.py
--- a/kivy/tools/packaging/pyinstaller_hooks/__init__.py
+++ b/kivy/tools/packaging/pyinstaller_hooks/__init__.py
@@ -334,7 +334,7 @@ def _find_gst_plugin_path():
     try:
         p = subprocess.Popen(
             ['gst-inspect-1.0', 'coreelements'],
-            stdout=subprocess.PIPE)
+            stdout=subprocess.PIPE, universal_newlines=True)
     except:
         return []
     (stdoutdata, stderrdata) = p.communicate()
diff --git a/kivy/tools/packaging/pyinstaller_hooks/pyi_rth_kivy.py b/kivy/tools/packaging/pyinstaller_hooks/pyi_rth_kivy.py
--- a/kivy/tools/packaging/pyinstaller_hooks/pyi_rth_kivy.py
+++ b/kivy/tools/packaging/pyinstaller_hooks/pyi_rth_kivy.py
@@ -5,7 +5,8 @@
 
 os.environ['KIVY_DATA_DIR'] = os.path.join(root, 'data')
 os.environ['KIVY_MODULES_DIR'] = os.path.join(root, 'modules')
-os.environ['GST_PLUGIN_PATH'] = os.path.join(sys._MEIPASS, 'gst-plugins')
+os.environ['GST_PLUGIN_PATH'] = '{}{}{}'.format(
+    sys._MEIPASS, os.pathsep, os.path.join(sys._MEIPASS, 'gst-plugins'))
 os.environ['GST_REGISTRY'] = os.path.join(sys._MEIPASS, 'registry.bin')
 
 sys.path += [os.path.join(root, '_libs')]


Test patch: