-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrt-hook-kivy.py
42 lines (34 loc) · 1.28 KB
/
rt-hook-kivy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from os.path import join, dirname
from os import environ, chdir, putenv
import sys
root = 'kivy_install'
if hasattr(sys, '_MEIPASS'):
# PyInstaller >= 1.6
chdir(sys._MEIPASS)
root = join(sys._MEIPASS, root)
elif '_MEIPASS2' in environ:
# PyInstaller < 1.6 (tested on 1.5 only)
chdir(environ['_MEIPASS2'])
root = join(environ['_MEIPASS2'], root)
else:
chdir(dirname(sys.argv[0]))
root = join(dirname(sys.argv[0]), root)
sys.path += [join(root, '_libs')]
if sys.platform == 'darwin':
sitepackages = join(root, '..', 'sitepackages')
sys.path += [sitepackages, join(sitepackages, 'gst-0.10')]
putenv('GST_REGISTRY_FORK', 'no')
environ['GST_PLUGIN_PATH'] = join(root, '..', 'gst-plugins')
environ['KIVY_DATA_DIR'] = join(root, 'data')
environ['KIVY_EXTS_DIR'] = join(root, 'extensions')
environ['KIVY_MODULES_DIR'] = join(root, 'modules')
environ['KIVY_EMBED'] = '1'
# Monkey-patch pygame to get around an issue with Pygame window icon and
# PyInstaller 2.1. See kivy issue #1638
import pygame.pkgdata
_original_getResource = pygame.pkgdata.getResource
def getResource(identifier, *args, **kwargs):
if identifier == 'pygame_icon.tiff':
raise IOError()
return _original_getResource(identifier, *args, **kwargs)
pygame.pkgdata.getResource = getResource