-
Notifications
You must be signed in to change notification settings - Fork 35
/
qt5.py
67 lines (54 loc) · 1.94 KB
/
qt5.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import sys
from modulegraph.modulegraph import MissingModule
def check(cmd, mf):
m = mf.findNode("PyQt5")
if m and not isinstance(m, MissingModule):
try:
# PyQt5 with sipconfig module, handled
# by sip recipe
import sipconfig # noqa: F401
return None
except ImportError:
pass
try:
import PyQt5
from PyQt5.QtCore import QLibraryInfo
except ImportError:
# PyQt5 in the graph, but not instaled
return None
# All imports are done from C code, hence not visible
# for modulegraph
# 1. Use of 'sip'
# 2. Use of other modules, datafiles and C libraries
# in the PyQt5 package.
try:
mf.import_hook("sip", m)
except ImportError:
mf.import_hook("sip", m, level=1)
qtdir = QLibraryInfo.location(QLibraryInfo.LibrariesPath)
if qtdir != os.path.dirname(PyQt5.__file__):
# Qt5's prefix is not the PyQt5 package, which means
# the "packages" directive below won't include everything
# needed, and in particular won't include the plugins
# folder.
print("System install of Qt5")
# Ensure that the Qt plugins are copied into the "Contents/plugins"
# folder, that's where the bundles Qt expects them to be
extra = {
"resources": [("..", [QLibraryInfo.location(QLibraryInfo.PluginsPath)])]
}
else:
extra = {}
if sys.version[0] != 2:
result = {
"packages": ["PyQt5"],
"expected_missing_imports": {"copy_reg", "cStringIO", "StringIO"},
}
result.update(extra)
return result
else:
result = {"packages": ["PyQt5"]}
result.update(extra)
return result
return None