11 |
11 |
12 from __future__ import unicode_literals |
12 from __future__ import unicode_literals |
13 from __future__ import print_function |
13 from __future__ import print_function |
14 try: |
14 try: |
15 import cStringIO as io |
15 import cStringIO as io |
16 import sip |
|
17 sip.setapi('QString', 2) |
|
18 sip.setapi('QVariant', 2) |
|
19 sip.setapi('QTextStream', 2) |
|
20 except (ImportError): |
16 except (ImportError): |
21 import io # __IGNORE_WARNING__ |
17 import io # __IGNORE_WARNING__ |
22 |
18 |
23 import sys |
19 import sys |
24 import os |
20 import os |
53 sys.exec_prefix) |
49 sys.exec_prefix) |
54 |
50 |
55 # Define blacklisted versions of the prerequisites |
51 # Define blacklisted versions of the prerequisites |
56 BlackLists = { |
52 BlackLists = { |
57 "sip": ["4.11", "4.12.3"], |
53 "sip": ["4.11", "4.12.3"], |
58 "PyQt4": ["4.7.5"], |
54 "PyQt5": ["4.7.5"], |
59 "QScintilla2": [], |
55 "QScintilla2": [], |
60 } |
56 } |
61 PlatformsBlackLists = { |
57 PlatformsBlackLists = { |
62 "windows": { |
58 "windows": { |
63 "sip": [], |
59 "sip": [], |
64 "PyQt4": ["4.9.2", "4.9.3"], |
60 "PyQt5": ["4.9.2", "4.9.3"], |
65 "QScintilla2": [], |
61 "QScintilla2": [], |
66 }, |
62 }, |
67 |
63 |
68 "linux": { |
64 "linux": { |
69 "sip": [], |
65 "sip": [], |
70 "PyQt4": [], |
66 "PyQt5": [], |
71 "QScintilla2": [], |
67 "QScintilla2": [], |
72 }, |
68 }, |
73 |
69 |
74 "mac": { |
70 "mac": { |
75 "sip": [], |
71 "sip": [], |
76 "PyQt4": ["4.9.2", "4.9.3"], |
72 "PyQt5": ["4.9.2", "4.9.3"], |
77 "QScintilla2": [], |
73 "QScintilla2": [], |
78 }, |
74 }, |
79 } |
75 } |
80 |
76 |
81 # Define file name markers for Python variants |
77 # Define file name markers for Python variants |
184 platBinDir = "/usr/local/bin" |
180 platBinDir = "/usr/local/bin" |
185 |
181 |
186 modDir = distutils.sysconfig.get_python_lib(True) |
182 modDir = distutils.sysconfig.get_python_lib(True) |
187 pyModDir = modDir |
183 pyModDir = modDir |
188 |
184 |
189 pyqtDataDir = os.path.join(modDir, "PyQt4") |
185 pyqtDataDir = os.path.join(modDir, "PyQt5") |
190 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): |
186 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): |
191 # it's the installer |
187 # it's the installer |
192 qtDataDir = pyqtDataDir |
188 qtDataDir = pyqtDataDir |
193 else: |
189 else: |
194 try: |
190 try: |
195 from PyQt4.QtCore import QLibraryInfo |
191 from PyQt5.QtCore import QLibraryInfo |
196 qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath) |
192 qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath) |
197 except ImportError: |
193 except ImportError: |
198 qtDataDir = None |
194 qtDataDir = None |
199 if qtDataDir: |
195 if qtDataDir: |
200 apisDir = os.path.join(qtDataDir, "qsci", "api") |
196 apisDir = os.path.join(qtDataDir, "qsci", "api") |
942 print('Your Python installation is missing the XML module.') |
938 print('Your Python installation is missing the XML module.') |
943 print('Please install it and try again.') |
939 print('Please install it and try again.') |
944 exit(5) |
940 exit(5) |
945 |
941 |
946 try: |
942 try: |
947 from PyQt4.QtCore import qVersion |
943 from PyQt5.QtCore import qVersion |
948 except ImportError as msg: |
944 except ImportError as msg: |
949 print('Sorry, please install PyQt4.') |
945 print('Sorry, please install PyQt5.') |
950 print('Error: {0}'.format(msg)) |
946 print('Error: {0}'.format(msg)) |
951 exit(1) |
947 exit(1) |
952 print("Found PyQt4") |
948 print("Found PyQt5") |
953 |
949 |
954 try: |
950 try: |
955 from PyQt4 import Qsci # __IGNORE_WARNING__ |
951 from PyQt5 import Qsci # __IGNORE_WARNING__ |
|
952 |
956 except ImportError as msg: |
953 except ImportError as msg: |
957 print("Sorry, please install QScintilla2 and") |
954 print("Sorry, please install QScintilla2 and") |
958 print("its PyQt4 wrapper.") |
955 print("its PyQt5 wrapper.") |
959 print('Error: {0}'.format(msg)) |
956 print('Error: {0}'.format(msg)) |
960 exit(1) |
957 exit(1) |
961 print("Found QScintilla2") |
958 print("Found QScintilla2") |
962 |
959 |
963 for impModule in [ |
960 for impModule in [ |
964 "PyQt4.QtGui", "PyQt4.QtNetwork", "PyQt4.QtSql", |
961 "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtSql", |
965 "PyQt4.QtSvg", "PyQt4.QtWebKit", |
962 "PyQt5.QtSvg", "PyQt5.QtWebKit", |
966 ]: |
963 ]: |
967 name = impModule.split(".")[1] |
964 name = impModule.split(".")[1] |
968 modulesOK = True |
965 modulesOK = True |
969 try: |
966 try: |
970 __import__(impModule) |
967 __import__(impModule) |
1019 exit(3) |
1016 exit(3) |
1020 except (ImportError, AttributeError): |
1017 except (ImportError, AttributeError): |
1021 pass |
1018 pass |
1022 |
1019 |
1023 # check version of PyQt |
1020 # check version of PyQt |
1024 from PyQt4.QtCore import PYQT_VERSION_STR |
1021 from PyQt5.QtCore import PYQT_VERSION_STR |
1025 pyqtVersion = PYQT_VERSION_STR |
1022 pyqtVersion = PYQT_VERSION_STR |
1026 # always assume, that snapshots are new enough |
1023 # always assume, that snapshots are new enough |
1027 if "snapshot" not in pyqtVersion: |
1024 if "snapshot" not in pyqtVersion: |
1028 while pyqtVersion.count('.') < 2: |
1025 while pyqtVersion.count('.') < 2: |
1029 pyqtVersion += '.0' |
1026 pyqtVersion += '.0' |
1034 if maj < 4 or (maj == 4 and min < 8): |
1031 if maj < 4 or (maj == 4 and min < 8): |
1035 print('Sorry, you must have PyQt 4.8.0 or higher or' |
1032 print('Sorry, you must have PyQt 4.8.0 or higher or' |
1036 ' a recent snapshot release.') |
1033 ' a recent snapshot release.') |
1037 exit(4) |
1034 exit(4) |
1038 # check for blacklisted versions |
1035 # check for blacklisted versions |
1039 for vers in BlackLists["PyQt4"] + PlatformBlackLists["PyQt4"]: |
1036 for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]: |
1040 if vers == pyqtVersion: |
1037 if vers == pyqtVersion: |
1041 print('Sorry, PyQt4 version {0} is not compatible with eric5.' |
1038 print('Sorry, PyQt5 version {0} is not compatible with eric5.' |
1042 .format(vers)) |
1039 .format(vers)) |
1043 print('Please install another version.') |
1040 print('Please install another version.') |
1044 exit(4) |
1041 exit(4) |
1045 print("PyQt Version: ", pyqtVersion) |
1042 print("PyQt Version: ", pyqtVersion) |
1046 |
1043 |
1047 # check version of QScintilla |
1044 # check version of QScintilla |
1048 from PyQt4.Qsci import QSCINTILLA_VERSION_STR |
1045 from PyQt5.Qsci import QSCINTILLA_VERSION_STR |
1049 scintillaVersion = QSCINTILLA_VERSION_STR |
1046 scintillaVersion = QSCINTILLA_VERSION_STR |
1050 # always assume, that snapshots are new enough |
1047 # always assume, that snapshots are new enough |
1051 if "snapshot" not in scintillaVersion: |
1048 if "snapshot" not in scintillaVersion: |
1052 while scintillaVersion.count('.') < 2: |
1049 while scintillaVersion.count('.') < 2: |
1053 scintillaVersion += '.0' |
1050 scintillaVersion += '.0' |
1077 """ |
1074 """ |
1078 Compile the .ui files to Python sources. |
1075 Compile the .ui files to Python sources. |
1079 """ # __IGNORE_WARNING__ |
1076 """ # __IGNORE_WARNING__ |
1080 global sourceDir |
1077 global sourceDir |
1081 try: |
1078 try: |
1082 from PyQt4.uic import compileUiDir |
1079 from PyQt5.uic import compileUiDir |
1083 except ImportError: |
1080 except ImportError: |
1084 from PyQt4.uic import compileUi |
1081 from PyQt5.uic import compileUi |
1085 |
1082 |
1086 def compileUiDir(dir, recurse=False, # __IGNORE_WARNING__ |
1083 def compileUiDir(dir, recurse=False, # __IGNORE_WARNING__ |
1087 map=None, **compileUi_args): |
1084 map=None, **compileUi_args): |
1088 """ |
1085 """ |
1089 Creates Python modules from Qt Designer .ui files in a directory or |
1086 Creates Python modules from Qt Designer .ui files in a directory or |
1090 directory tree. |
1087 directory tree. |
1091 |
1088 |
1092 Note: This function is a modified version of the one found in |
1089 Note: This function is a modified version of the one found in |
1093 PyQt4. |
1090 PyQt5. |
1094 |
1091 |
1095 @param dir Name of the directory to scan for files whose name ends |
1092 @param dir Name of the directory to scan for files whose name ends |
1096 with '.ui'. By default the generated Python module is created |
1093 with '.ui'. By default the generated Python module is created |
1097 in the same directory ending with '.py'. |
1094 in the same directory ending with '.py'. |
1098 @param recurse flag indicating that any sub-directories should be |
1095 @param recurse flag indicating that any sub-directories should be |